Now, there is a file named a.txt whose contents is as follows:
I want to store them useing list structure,Code:adddd dddddddddd sdf
how to solve it ?
Now, there is a file named a.txt whose contents is as follows:
I want to store them useing list structure,Code:adddd dddddddddd sdf
how to solve it ?
1) open the file as an ifstream
2) use getline on the ifstream to get a string
3) push a copy of the string onto the list.
To check:Code:ifstream file("path_to_file",ios::in); list<string> data; string buffer; while (getline(file,buffer)) data.push_back(buffer); file.close();
Code:list<string>::iterator it = data.begin(); while (it != data.end()) { cout << *it <<endl; it++; }
C programming resources:
GNU C Function and Macro Index -- glibc reference manual
The C Book -- nice online learner guide
Current ISO draft standard
CCAN -- new CPAN like open source library repository
3 (different) GNU debugger tutorials: #1 -- #2 -- #3
cpwiki -- our wiki on sourceforge