if statment error

I have an if statement that should either match a text variable that the user has entered and a another text variable that has been got from an array but they won't match even if they are the same,Im at a lost with it. Help would be gratefully received.



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
void displayQuestion(int noQuestion, string questionArray[], string answerarray[], string answer, double scorearray, double finalscore){

	cout << questionArray[noQuestion] << endl;
	cout << "enter an answer " << endl;
	cin >> answer;
	//cout << "User answer: " << answer << endl;
	//cout << "Correct answer: " << answerarray[noQuestion] << endl;

	if (answer == answerarray[noQuestion]){
		cout << "WELL DONE" << endl;

	}
	else if (answer != answerarray[noQuestion]){ cout << "nope" << endl; }

}//readfromFile 
You're sure that everything matches up when you input args?

i.e. answerarray[a] matches up with questionArray[a] and so on?

And I'm sure you made sure you typed everything correctly, but try putting answer = answerArray[noQuestion]; after the input and before the if statement. Let me know how that runs.
Topic archived. No new replies allowed.