I have a text file in the following format:
info data1 data2 info data1 data2 data3 data4...
The problem is that the amount (and length) of data can be very large and cause run-time problems when using getline() . Therefore, I cannot read the entire string in std::string . I tried the following:
for(int i=0; i<SOME_CONSTANT ; i++){ string info, data; cin >> info; while(cin.peek() != '\n' && cin >> data){
However, cin.peek() did not. Information is read into data in a while loop and runs programs. How can i fix this?
c ++ string io newline cin
Varaquilex
source share