So I want to create a file to output some information into and want to include to user inputted strings in the name.
1 2 3 4 5 6 7 8
|
ofstream gamefile
string team1;
string team2;
cout << "Please input the team names:" << endl << "Team 1: " << endl;
cin >> team1;
cout << "Team 2: " << endl;
cin << team2;
gamefile.open (team1 "@" team2 ".txt", ios::app);
|
So team1 and team2 are inputted user strings while @, .txt I need to add in.
Last edited on
What file are you trying to open?
I'm trying to create a file named "[team1]@[team2].txt" and then print information into it.
std::ofstream gamefile(team1 + '@' + team2 + ".txt", std::ios::app);
or
gamefile.open(team1 + '@' + team2 + ".txt", std::ios::app);
on an already existing stream.
Prefer the first where possible.
Last edited on