This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on May 7th, 2013  |  syntax: C++  |  size: 0.62 KB  |  views: 27  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. // SUGGESTION 1
  2.  
  3. istringstream iss(line, istringstream::in);
  4. int nWord = 0;
  5. int i=0;
  6. while( (nWord < 2000) && (iss >> word) )
  7. {
  8.     strncpy(temp_eng_word[nWord], word.c_str(), 49);
  9.         temp_eng_word[nWord][49] = '\0'; // if it's not already zero-allocated
  10.     ++nWord;
  11.         cout <<temp_eng_word[nWord]<<endl; // Skips first word in line
  12. }
  13.  
  14. // SUGGESTION 2
  15. vector<string> words;
  16. istringstream iss(line, istringstream::in);
  17. while(iss >> word)
  18. {
  19.     words.push_back(word);
  20.         cout << word <<endl;// PRINTS THE FIRST WORD IN EACH LINE
  21.         copy(istream_iterator<string>(iss), istream_iterator<string>(), back_inserter(words));
  22. }
clone this paste RAW Paste Data