fork download
  1. #include <sstream>
  2. #include "iostream"
  3.  
  4. using namespace std;
  5.  
  6. int main(){
  7. string line = "test one two three.";
  8. string arr[4];
  9. int i = 0;
  10. stringstream ssin(line);
  11. while (ssin.good() && i < 4){
  12. ssin >> arr[i];
  13. ++i;
  14. }
  15. for(i = 0; i < 4; i++){
  16. cout << arr[i] << endl;
  17. }
  18. }
Success #stdin #stdout 0s 3428KB
stdin
Standard input is empty
stdout
test
one
two
three.