|
| |||||||||||||||||||||||||||||||||||||||||||
| karma4561 (7) | |
|
Hello everybody, I´m reading a text file with words, and something strange happens. Suppose that I´m reading the following words (this words are in the text file): cebolla yuca When I opened this words with the getline method that is in the stream class, I got this: cebolla yucalla As you can see, the word yuca take the last tree letter of the word cebolla. Someone knows why this is happening? I guess that I did not flush the stream. Best Regards. | |
|
|
|
| ropez (310) | |
| Can you post the code that you use to read from the file? | |
|
|
|
| karma4561 (7) | |||
Sure:
| |||
|
|
|||
| ropez (310) | |||||
|
I don't know if I understand the problem. After calling getline(), lista should contain some characters followed by a null character ('\0'). I can only give you a general advice: Instead of this:
try this:
And do the same everywhere you're using char[] or char*. Replace it with std::string. | |||||
|
|
|||||