creating a txt file to a exact c: location

hi how do you create a txt file to a C: location (example file.location = "C:\Program Files (x86)\mr. folder"
in that case u have to specify the complete file path in the constructor of the fstream statement.
1
2
3
4
5
6
7
8
9
10
11
12
#include <fstream>
#include <string>
using namespace std;

int main()
{
    const char *path="/home/user/file.txt";
    ofstream file(path);
    string data("you are seeing this in www.cplusplus.com");
    file << data;
    file.close();
}
Topic archived. No new replies allowed.