テック
c++の文字列処理(分割)

文字列の分割(sscanf) >> >|cpp| #include <iostream> #include <string> using namespace std; int main() { std::string str( "A:B" );
char lhs,rhs; sscanf(str.c_str(), "%c:%c", &lhs, &rhs); cout << lhs << ":" << rhs << endl; return 0
} ||< << 文字列の分割(sstream) >> >|cpp| #include <sstream> #include <iostream> #include <string> using namespace std; int main() { string str( "123 456 789" ); stringstream ss(str);
int n; while(ss >> n){ cout << n << endl; } return 0;
} ||< <<</string></iostream></sstream></string></iostream>


