简体   繁体   中英

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

Very new to C++ and when I compile I get this error:

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

What on earth does this mean? I presume it's something memory related, I have not initiated the array or something along those lines?

Here is my code:

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类型

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM