when ever i try to compile the code it keeps returning this error
conversion from `std::string*' to non-scalar type `std::string' requested
what exatly am i doing wrong?
heres the source.
#include <iostream>
#include <string>
#include <conio.h>
using namespace std;
void showScore(int, bool, string);
int main()
{
int count;
int numcorrect = 0;
bool rightAnswer[20];
string correctAnswers[]= {"B","D","A", "A", "C", "A", "B", "A", "C", "D"
,"B", "C", "D", "A", "D", "C", "C", "B", "D", "A"};
string studentAnswers[20];
for(int i = 0, count = 1; i <= 19; i++, count++)
{
cout << "What is your answer to Question #" << count << "?: ";
cin >> studentAnswers[i];
while (studentAnswers[i] != "A" && studentAnswers[i] != "B" && studentAnswers[i] != "C" && studentAnswers[i] != "D")
{
cout << "Please answer in Capital letters with either A, B, C, or D.";
cin >> studentAnswers[i];
}
}
for (int n = 0; n <= 19; n++)
{
if(correctAnswers[n] == studentAnswers[n])
{
rightAnswer[n] = true;
numcorrect++;
}
else
rightAnswer[n] = false;
}
showScore(numcorrect, rightAnswer,studentAnswers);
getch();
return 0;
}
void showScore(int numcorrect, bool rightAnswer[],string studentAnswers[])
{
if (numcorrect >= 15)
{
cout << "You got " << numcorrect << " correct out of 20!!" << endl;
cout << "You passed!!" << endl;
}
else
cout << "You got " << numcorrect << " correct out of 20." << endl;
cout << "You did not pass the exam." << endl;
for (int t = 0, count = 1; t <= 19; t++, count++)
{
if(rightAnswer[t] == true)
{
cout << count << ".\t" << studentAnswers[t] << "\tCorrect" << endl;
}
else
cout << count << ".\t" << studentAnswers[t] << "\tIncorrect" << endl;
}
}