Produce a file or w/e with std?

I want to know how to create a file with using the std::
i only know std::remove but this time i want to add a file XD
What are you doing? I can't even understand your question. Better to have too much detail than too little.
If you're trying to add to the std:: namespace I believe it is possible; namespaces are compiled across multiple translation units.
You can create an ofstream object. When you open a file for output if it doesn't exist it will be created
[...]
string answer;
cout << "Do you like cheese? " << endl;
cin >> answer;
if ( answer == "Yes" ) {
cout << "Nice" << endl;
std::xxx("CheeseFTW.txt");
}
else if ( answer == "No" ) {
cout << "Cheese is good dude!" << endl;
std::remove("testfile.txt)")
}
[...]

Well something like this,
the xxx replace the command of creating a file which i dont know.
OK.
In that case you need to learn how to use the STL's file IO classes (fstream, ofstream, ifstream). You can find an explanation in the last chapter of this website's tutorial.
http://www.cplusplus.com/doc/tutorial/files/
I don't ever recall a std::remove though.
Last edited on
http://www.cplusplus.com/reference/algorithm/remove/
It has nothing to do with files.
I never thought it's possible to delete files with standard C, but now as I'm thinking about it, I don't know why I thought that.
I see... I wonder why that wasn't implemented for fstream.
Last edited on
Topic archived. No new replies allowed.