ifstream


how can i use ifstream to display the content of a txt file in c++.
1
2
3
ifstream file("file.txt");
string line;
while (getline(file,line))cout << line << endl;
- Declare an ifstream variable.

- Use it to read data into the stream.

- Save the data from the stream to another variable. Remember that this casts the data to match the type of the variable.

- Use that variable in your application.

Does this help?
thanks
that works
Topic archived. No new replies allowed.