Displaying .txt file contents on the console

I have a program that extracts data from a file, does calculations, and then outputs the original contents plus some new data in an output file. Both files are .txt files created in notepad with nothing but text. What I cannot figure out, though, is what code I need to type in in my editor in order for my output file contents to be displayed in/on the console. Is there any way to accomplish this? I mean, I know it's possible to extract data from a file, do calculations in the editor, compile, and then display the new stuff on the console, so I figure there must be a way to do what I'm asking..
Last edited on
Does anyone know if this is possible?
Use cout to make output to the screen, like:

cout << "Hello world ";
I'm trying to display the contents of the file. So, would I type something like the following?

cout<<"E:\classtestavg.txt"<<endl;
Your code just prints
E:\classtestavg.txt
to the screen.
You have to read file and print its content to the screen.

You may try something like it:
1
2
3
4
5
6
ifstream f("E:\classtestavg.txt");
string s;

while (getline(f,s))
 cout << s << endl;
Topic archived. No new replies allowed.