fork download
  1. #include <string>
  2. #include <iostream>
  3.  
  4. using namespace std;
  5.  
  6. int main(int argc, char** argv)
  7. {
  8. string str = "Welcome to the computer world.";
  9. cout<<str.length();
  10. string strWords[5];
  11. short counter = 0;
  12. for(short i=0;i<str.length();i++){
  13. strWords[counter] += str[i]; // Append fixed
  14. if(str[i] == ' '){
  15. counter++;
  16. }
  17. }
  18. for(short i=0;i<5;i++){
  19. cout << strWords[i] << "(" << strWords[i].size() << ")" << endl;
  20. }
  21. return 0;
  22. }
Success #stdin #stdout 0s 15240KB
stdin
Welcome to the computer world.
stdout
30Welcome (8)
to (3)
the (4)
computer (9)
world.(6)