Invalid conversion from ‘char’ to ‘const char *’

char load;
string intro = LoadFileToString( "Intro.txt" );

cout << intro << "> ";

cin >> load;

string loadedFile = LoadFileToString( load );

You’re trying to pass a char to LoadFileToString which takes in a char*. I think what you intend to do is this

string intro = LoadFileToString( "Intro.txt" );    
cout << intro << "> ";
string load;
cin >> load;    
string loadedFile = LoadFileToString( load.c_str() );

Notice that I’m reading the input into a string instead of a char since the LoadFileToString expects a (C-style) string to be passed in; instead you’re reading and trying to pass a character to it. Once the input is read through a string, a C-style string can be obtained by calling string::c_str() function.

Leave a Comment