char NAME[256];
cin.getline (NAME,256);
ofstream fout(\"NAME.txt\"); //NAME???????
What i need to do to create file with NAME name?
You could try:
#include
#include
#include
int main() {
// use a dynamic sized buffer, like std::string
std::string filename;
std::getline(std::cin, filename);
// open file,
// and define the openmode to output and truncate file if it exists before
std::ofstream fout(filename.c_str(), std::ios::out | std::ios::trunc);
// try to write
if (fout) fout << "Hello World!\n";
else std::cout << "failed to open file\n";
}
Some useful references: