fork(3) download
  1. #include <iostream>
  2. #include <sstream>
  3. #include <string>
  4. using namespace std;
  5.  
  6. int main() {
  7.  
  8. string line;
  9. getline(cin,line);
  10. stringstream ss(line);
  11.  
  12. string word;
  13.  
  14. int count=0;
  15. while(ss>>word){
  16. count++;
  17. }
  18. cout<<count<<endl;
  19. return 0;
  20. }
Success #stdin #stdout 0s 3432KB
stdin
Hello World This Is String Stream
stdout
6