generate a text file?

how would you go about making a program generate a text file?
If you create an ofstream and bind it to a file that does not exist, it will automatically create the file.
1 last question. How would you make the program scan to see if it already exists?
There may be a flag to prevent it from engendering a file to fill an empty path. So if there was such a thing, you could check an ofstream for validity after opening. If it was bad, you would know the file didn't exist.
An alternative is to open an ifstream to a file, because it will never create a file against its path afaik. If the open failed you know it didn't work. But I don't know of a cleaner, prettier way.
Topic archived. No new replies allowed.