Trouble debugging code for a simple program.

I am getting the error message 'in function "int main()': invalid conversion from'char*'to 'char' initializing argument 1 of 'bool studentResults(chat char, bool, int'". i also get this message for the second argument of the same function, line 38.

I've been digging this for about an hour, trying to replace the char to string therefore 'A' to "A" for instance, but unsuccessfully.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#include <iostream>
#include <conio.h>
#include <string>

using namespace std;

void pause();
bool studentResults(char, char, bool, const int);

int main()
{
	const int ANS = 20;
	
	char answers[ANS] = {'B', 'D', 'A', 'A', 'C', 'A', 'B', 'A', 'C', 'D',
		             'B', 'C', 'D', 'A', 'D', 'C', 'C', 'B', 'D', 'A'},
             sAnswer[ANS];
		 
	bool pass;
	
	cout << "This program will ask for the student's answer to\n"
		 << "his driving test. And will tell you whether he passed\n"
		 << "or not.\n";
		 
		for (int count = 0; count < ANS; count ++)
		{
			cout << "\nAnswer for question n° " << count + 1 << "?";
			cin >> sAnswer[count];
			
				if (sAnswer[count] != 'A' && sAnswer[count] != 'B' &&
                                    sAnswer[count] != 'C' && sAnswer[count] != 'D')
				{
					cout << "\nThe answer can only be A, B, C, or D!\n"
						 << "\nAnswer for question n° " << count + 1 << "?";
					cin >> sAnswer[count];
				}
		}
		
	pass = studentResults (answers,  sAnswer, pass, ANS);
	
		if (pass)
			cout << "\n\nCongratulations! You passed your driving test!";
		else
			cout << "\n\nSorry, you didn't pass your driving test.";
		
	pause();
}

bool studentResults( char answers[], char sAnswer[], bool pass, const int ANS)
{
	int goodAnswers = 0,
		badAnswers;
	
	cout << "\n\n\t\tTEST RESULTS\n";
    	
		for (int count = 0; count < ANS; count ++)
		{
			cout << "\nQuestion " << count + 1 << ", good answer: "
                 << answers[count]
				 << "----- Your answer: " << sAnswer[count] << " _____ ";
				 
				if( answers[count] == sAnswer[count])
				{
					cout << "V";
					goodAnswers += 1;
				}
				else
					cout << "X";
		}
		badAnswers = ANS - goodAnswers;
	
			if (goodAnswers >= 15)
				pass = true;
		
		return(pass);
}

void pause()
{
	printf("\n%S", "Press any key to continue");
	_getch();
	printf("\n\n");
	return;
}

Thank you in advance for any answers!
Last edited on
The prototype and function definition need to match. The prototype has the first two arguments as single char variables, but the definition (and the call at line 38) has them as character arrays.

bool studentResults(char, char, bool, const int);
bool studentResults(char answers[], char sAnswer[], bool pass, const int ANS)
Oh wow i didn't know you had to define arguments as arrays in the prototype (i just learned arrays). found out that i was just missing two '*' in the prototype.

Thank you wildblue, have a good day!
Topic archived. No new replies allowed.