[b] A little <fstream> mishap [/b]

Hi guys, hows your morning? I hopes its good!

Im a little confused on file input and output.
I have a textbook which shows a simple output to a file. I modified it slightly to my own liking.
1
2
3
4
5
6
7
8
9
10
#include <fstream>

int main ()
{
cout <<"This program stores \"WASUUUUUP\" in a text file called \"Message\".\n";
ifstream file_out ("C:\\Users\\Bob\\Desktop\\Message.txt");
file_out <<"WASUUUUUP\n";
cout << "File has been createdn\n";
return 0;
}


Bob is not my real name :)

Anyways, this books pretty old, published in 1995.
I realize you change <fstream.h> to <fstream> and the book also had a void type for main ().
I also changed the A: to a C: since I do not have a ready floppy disk.

However my main issue is that I'm having trouble with ifstream and file_out.
I understand that ifstream is a class, and file_out is its object, but what is in the parenthesis and the path, the thing which creates the file.
Also, is file_out old? Can you change it? Is there a new way?
the books not very clear here, and I'm so fuzzled! xD
A clear explanation would be sincerely helpful.
Thanks!
Cheers!

Ignore to tags in the title. I tried to make it bold, but it failed epicly...
Last edited on
I think it should be ofstream instead of ifstream. You can name file_out to whatever you want.
Topic archived. No new replies allowed.