#include <iostream>
#include <fstream>
int main()
{
std::cout << "Opening output file..." << std::endl;
std:fstream ofile("bobinsurance.txt");
if (!ofile.fail()) {
std::cout << "Writing to file...";
ofile << "password " << std::endl;
}
else
std::cout << "cannot open";
return 0;
}
This code works fine, and it goes into the dir. Of my complier.
If I code std:fstream ofile("c:\My Doucments\text.txt”};
The complier comes back with invalid escape.
I want to write a file to My Documents……..
#include <fstream>
int main()
{
std::cout << "Opening output file..." << std::endl;
std:fstream ofile("bobinsurance.txt");
if (!ofile.fail()) {
std::cout << "Writing to file...";
ofile << "password " << std::endl;
}
else
std::cout << "cannot open";
return 0;
}
This code works fine, and it goes into the dir. Of my complier.
If I code std:fstream ofile("c:\My Doucments\text.txt”};
The complier comes back with invalid escape.
I want to write a file to My Documents……..