【发布时间】:2015-07-19 08:49:27
【问题描述】:
我正在尝试使用此功能
int input(int marks[classMax][3], string names[classMax], float& avg)
{
for (int i = 0; i < students; i++)
{
for (int j = 0; j < 3; j++)
{
fin >> marks[i][j];
}
fin >> names[i];
}
}
将带有学生姓名的分数列表放入两个数组中。名单如下:
M1 M2 M3 FirstName LastName,其中 M 表示标记。
循环工作正常,但是当它到达名字和姓氏之间的空间时,程序似乎只将名字写入数组。我尝试使用fin.get 和fin.getline(),但出现此错误:
error: no matching function for call to 'std::basic_ifstream<char>::get(std::strings&, int)'
【问题讨论】:
标签: c++ fstream ifstream getline