Creating text files
I'm not sure if you're to familiar with batch but here is a code...
What that does is creates a text file on the desktop named hi.txt and inside the text file is the word Hello. Then, it starts the text file. My question is, how can I do this in C++?
echo Hello >c:\windows\desktop\hi.txt
start /m c:\windows\desktop\hi.txt
Look into fstream. In particular, ofstream (output file stream). It works much like ostream (i.e. cout). If the file you are outputting to does not exist, it will be created.
To launch the file, the simplest would be a system call:
Basically, what you'd put in the batch file (system calls) can be mirrored in a system call. Though, beware: system calls are slow and non-portable. It is a good idea to wrap them in some standard interface so that multiple platforms can be supported.
int main( )
std::system("start /m c:\windows\desktop\hi.txt");
It says cstdlib doesn't exist. Thats ok thought because I am just now going into the file I/0 tutorial. I guess I should've read that first :rolleyes:
Oh it showed up as non exisiting because I put .h after cstdlib. I figured it out now. Thx for the help.
Likely reason is that your compiler isn't standards compliant. Try <stdlib.h>