Output a .txt file

How can I show the content of a txt file in the console, just as it is in the file?

I mean, I've already tried line by line, but I need to have some spaces. And with that method, he only shows the parts where there are charaters.

So if, in a txt file, I have something like this:

.......... Hola!

I want to print that in the console as:

.......... Hola!

Don't pay attention to the points... They just represent spaces.
you can use getline function to get data from file and cout that data to the console.
Because getline won't ignore white space.

For example:
1
2
3
4
5
ifstream file;
file.open("data.txt");
string line;
getline(file, line);
cout << line << endl;
Last edited on
THANKS! I really thank you! It worked! And it worked amazingly!

I should have thought about getline() o.O
Topic archived. No new replies allowed.