前田稔(Maeda Minoru)の超初心者のプログラム入門
#include <iostream> #include <sstream> using namespace std; istringstream iss("1, 3.14 ; ABC 123"); int main() { int num1, num2; float f; string str; char c1,c2; iss >> num1 >> c1 >> f >> c2 >> str >> num2; // 文字列を展開 cout << "num1=" << num1 << " f=" << f << " str=" << str << " num2=" << num2 << endl; char c; cin.get(c); return 0; } |
num1=1 f=3.14 str=ABC num2=123 |