错误:从“void*”到“char”c++数组的转换无效

error: invalid conversion from ‘void*’ to ‘char’ c++ array

本文关键字:数组 c++ 转换 无效 char void 错误      更新时间:2023-10-16

C++非常新,当我编译时,我得到了这个错误:

error: invalid conversion from ‘void*’ to ‘char’

这究竟意味着什么?我想这是与记忆有关的,我没有启动数组或类似的东西?

这是我的代码:

char students[150][150];
int main()
{
    readFile();
}
void readFile()
{
    string line;
    ifstream file("scores.txt");
    for(int i = 0; i  <  150; i++) {
        for (int x = 0; x < 150; x++) {
            students[i][x] = getline(file, line, ' ');
        }
    }
    for(int i = 0; i  <  150; i++) {
        cout << students[i][i];
    }
}

getline返回一个basic_stream,并且不能将其设置为char 类型