| test-sscanf.C |
// 古い方法を使うと
#include <iostream.h>
#include <string>
#include <cstdio>
int main()
{
double x;
int n;
string s;
s = "123.4 56";
sscanf(s.c_str(), "%lf%d", &x, &n);
cout << "x=" << x << ", n=" << n << endl;
return 0;
}
|
| test-strstream3.C |
#include <iostream.h>
#include <string>
#include <strstream.h>
int main()
{
double x;
int n;
string s;
s = "123.4 56";
istrstream is(s.c_str());
is >> x >> n;
cout << "x=" << x << ", n=" << n << endl;
return 0;
}
|