Reputation: 49
int a
cin>>a;
ofstream file;
file.open("a.txt");
I want to create a .txt file with the code entered by the user. Please help.
Upvotes: 0
Views: 356
Reputation: 7688
Need to convert the input to std::string
:
int a;
cin>>a;
ofstream file(std::to_string(a) + ".txt");
Upvotes: 1