gpt4 book ai didi

c++ - 错误 : invalid conversion from ‘void*’ to ‘char’ c++ array

转载 作者:行者123 更新时间:2023-11-27 23:22:53 25 4
gpt4 key购买 nike

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_istream,不能设置为char类型

关于c++ - 错误 : invalid conversion from ‘void*’ to ‘char’ c++ array,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11587028/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com