Need help with a simple VC++ 6 console app with an output file (EASY)
Posted on 2002-06-10
Ok, here's a problem thats probably simple, but its driving me completely insane, and I thought some of you C/C++ whizzes would be able to help.
1) I start by creating a "Hello World" console application, using VC++ 6.0 (It's one of the options when creating a new project). The application is meant to be in C++.
2) I want to add to the application such that it opens a file, prints "You printed hello world" in it, and then closes the file.
3) I included iostream and fstream.h and then changed the MAIN function to:
int main (...) //can't remember default params at the moment =P
printf ("hello world");
test << "you printed hello world!";
For whatever reason, this just doesn't work!!! It says the ofstream is undefined, and then complains about all the test.* calls, so I figured I must be including wrong, or something. I was also getting an error about reaching the end of a preprocessor directive or something.
If anyone could do a SIMPLE program for VC++ 6 similar (takes all of 2 minutes) to what I've done that actually works, I would be greatful to be able to test it to see if it works on my computer.
Thanks in advance!