这是我的代码
ofstream Team_txt("Team.txt", ios_base::app);
cout << "Please enter team name: ";
cin >> Team_Name;
cout << "Please enter team Id: ";
cin >> Team_ID;
cout << "Please enter Captain name: ";
cin >> Team_Captain;
cout << "Please enter Total_Score name: ";
cin >> Total_Score;
Team_txt << Name << ' ' << Team_ID << ' ' << Team_Captain << ' ' << Total_Score << endl;
Team_txt.close();
我希望看到
但我明白了:
在第二张图片中,每行前面有一个空格,顶部有一个空行
答案 0 :(得分:2)
在这一行:
Team_txt << Name << ' ' << Team_ID << ' ' << Team_Captain << ' ' << Total_Score << endl;
名称未在您的代码中定义,请检查它可能需要Team_Name
而不是name
。