speak
speak

Reputation: 5382

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];
    }
}

Upvotes: 0

Views: 833

Answers (1)

Rodrigo Gurgel
Rodrigo Gurgel

Reputation: 1736

getline returns a basic_istream, and you can't set it to the type char

Upvotes: 4

Related Questions