Use word.c_str()
to get a const char*
out of the std::string
Also, I don't understand the point of your nested for
loop, you may want to do something like this instead (using strncpy
to copy a maximum of 49 char
with zero-padding if needed, and ensure the last char
of the string is always zero) :
istringstream iss(line, istringstream::in);
int nWord = 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;
}
Note that it would be simpler to use std::vector<std::string>
to store your words :
vector<string> words;
istringstream iss(line, istringstream::in);
while(iss >> word)
{
words.push_back(word);
}
Which could be done without a loop using std::copy
:
copy(istream_iterator<string>(iss), istream_iterator<string>(), back_inserter(words));