SHARE
TWEET

Untitled

a guest May 7th, 2013 27 Never
  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. }
RAW Paste Data
Top