When using the general class fstream, you may have to specify that you want to use the file for output by including the ios::out value after the filename in the open command i.e.
- filestream.open("test.txt", ios::out);
I haven't used fstream (instead I use ifstream and ofstream, more specific versions of fstream, which you may want to explore), so I'm not sure if this is correct.
As far as specifying the filepath, I assume you tried to open something like
- filestream.open("C:\My Documents\Programming Stuff\test.txt");
at which point the compiler would complain about not recogning '\M' or '\P'. Simply replace each '\' by '\\' - the example would become:
- filestream.open("C:\\My Documents\\Programming Stuff\\test.txt");
The escape character for a single backslash is two backslashes - if you don't include this in the filename, your compiler will think you are trying to make escape sequences rather than making a filename.