I just started a program today, and only got the first function finished when I ran into problems. Just my luck. Anyway, I'm not exactly sure what the problem is, because I have just recently learned about arrays. Well...here's what I have(like I said, its the very beginning):
/*Include Statements*/
#include <stdio.h>
/*Function Prototypes*/
void getnames(char pl1, char pl2);
/*Main Function*/
int main(void)
{
/*Variable Declaration*/
char player1[20], player2[20];
getnames(player1, player2);
printf("%c %c", player1, player2);
return 0;
}
/*Function to Get the Players' Names*/
void getnames(char pl1[20], char pl2[20])
{
printf("Player 1, Please Enter Your Name: ");
scanf(" %c", &pl1);
printf("Player 2, Please Enter Your Name: ");
scanf(" %c", &pl2);
return;
}
The error I get is this:
"error C2664: 'getnames' : cannot convert parameter 1 from 'char [20]' to 'char'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast"
I am using The Microsoft Visual C++ compiler (v6.0)...sometimes I get errors with it that I won't with Turbo C++. Anyway, I tried using getnames(&player1[0], &player2[0]), though they (to my knowledge) do the same thing. I really dunno what's wrong, all I want to do is get and store the 2 players' first names (I added the printf to see if it was working right, little did I know that I wouldn't even get that far) into the arrays.
But please remember, I'm new to arrays, so don't be too harsh if its a glaring error...I won't pick up on those for some time yet... =P
Any help would be much appriciated. = )
- Pat