Error: cannot convert 'std::string* {aka std::basic_string<char>*}' to 'char*' for argument '2'

Hello! I'm currently writing a quiz show code but I'm continually getting an error that has me at the end of my wits. This is the error and the function it occurs in:

Error:
QuizShowProj.cpp:272:60: error: cannot convert ‘std::string* {aka std::basic_string<char>*}’ to ‘char*’ for argument ‘2’ to ‘int show_question(std::string (*)[5], char*, int)’
responseStatus[i] = show_question(qArray, aArray, num);

Function:
int play_game(string qArray[AMOUNT][5], string aArray[AMOUNT], int fixedSeed, bool used[AMOUNT], string userName) {

int score = 0;
int responseStatus[6];
int num = 0;


for (int i = 0; i < 6; i++) {
responseStatus[i] = 0;
}

srand(fixedSeed);

cout << endl << userName << " ";

for (int i = 0; i < 6; i++) {
num = rand() % 50;

while (used[num] == true) {
num = rand() % 50;
}

used[num] = true;

responseStatus[i] = show_question(qArray, aArray, num);
}

for (int i; i < 6; i++) {
switch (responseStatus[i]) {
case 1: score += 10 ^ i;
break;
case 2: score += 5 ^ i;
break;
case 3: score += 0;
break;
}
}

return score;
}
Last edited on
Addon: This is the function used in play_game:
int show_question(string qArray[AMOUNT][5], char aArray[AMOUNT], int count) {

char answer;
char retryAns;
int whatHappened = 0; // If = 1, correct answer. If = 2, incorrect answer, retried and correct. If = 3, skip question. If = 4, incorrect second answer; end.

answer = player_try(qArray, count);

if (answer == aArray[count]) {
cout << "You were right! " << answer << " was the correct choice!" << endl;
whatHappened = 1;
}
else {
cout << "Your answer was incorrect. Would you like a second try? Y/N: " << endl;
cin >> retryAns;
toupper(retryAns);

while (retryAns != 'Y' && retryAns != 'N') {
cout << "Please respond with 'Y' or 'N': ";
cin >> retryAns;
toupper(retryAns);
}

if (retryAns = 'Y') {
whatHappened = player_second_try(qArray, aArray, count, answer);
}
else if (retryAns = 'N') {
whatHappened = 3;
}
}
return whatHappened;
}
Please edit your posts and add code formatting with [ code] and [ /code] tags (minus the spaces).

Show us what line 272 is. Also, you're using = (assignment) in places where you are meaning to use == (equality test).

Edit: Do you understand the difference between
char array[N];
and
string array[N];
?

The former is an array of individual characters.
The latter is an array of C++ strings (which each hold sequences of characters). You are trying to pass the former as the latter into show_questions.
Last edited on
Topic archived. No new replies allowed.