Mark44
Mentor
- 38,048
- 10,543
Of course it does. Each iteration of the loop resets str to a new value.yungman said:I tried your suggestion, it still erase the old data in str every time a new line is read from file and write to str.
I already said why this isn't a good idea for all but toy programs. If you run your program on a large file (several terabytes) the program will run out of memory.yungman said:I don't see this can achieve what I want...to read the stream from file and store the complete content into either an array or vector.