fork download
  1. #include <sstream>
  2. #include <string>
  3. int main()
  4. {
  5. std::istringstream stream{"Chief Executive Officer\n"
  6. "John Smith\n"
  7. "32"};
  8. std::string position;
  9. std::string first_name;
  10. std::string family_name;
  11. int age;
  12. if (std::getline(stream, position) &&
  13. stream >> first_name >> family_name >> age) {
  14. // Use values
  15. }
  16. }
Success #stdin #stdout 0s 16064KB
stdin
Standard input is empty
stdout
Standard output is empty