Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // SUGGESTION 1
- istringstream iss(line, istringstream::in);
- int nWord = 0;
- int i=0;
- while( (nWord < 2000) && (iss >> word) )
- {
- strncpy(temp_eng_word[nWord], word.c_str(), 49);
- temp_eng_word[nWord][49] = '\0'; // if it's not already zero-allocated
- ++nWord;
- cout <<temp_eng_word[nWord]<<endl; // Skips first word in line
- }
- // SUGGESTION 2
- vector<string> words;
- istringstream iss(line, istringstream::in);
- while(iss >> word)
- {
- words.push_back(word);
- cout << word <<endl;// PRINTS THE FIRST WORD IN EACH LINE
- copy(istream_iterator<string>(iss), istream_iterator<string>(), back_inserter(words));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement