ERRORS POSTED AT BOTTOM WHATS WRONG???? WHAT CAN I DO??
Code:
#include <stdio.h>
#include<string.h>
int playerlives[2] = {5,5};
int round=1;
int playerscore[2] = {0,0};
int currentplayer = 0;
int templives;
void swapplayers();
void activeplayerstats(char,int,int,int);
void playround(char name[], int* numlives, int*score, int round);
int main() {
int numlives = 5;
int score = 0;
char playername[2][100]= {0};
char name[100]= {0};
printf("Player one, what is your name?\n");
scanf("%s", name[0]);
printf("Player two, what is your name?\n");
scanf("%s", name[1]);
strcpy(name,playername[currentplayer]);
numlives = playerlives[currentplayer];
score = playerscore[currentplayer];
while (numlives>0)
{
templives=numlives;
playround(name, &numlives, &score, round);
round+=1;
activeplayerstats(name[currentplayer], score, numlives,currentplayer);
if (numlives==0)
{
printf("Your Game is Over.\n");
}
swapplayers();
}
printf("Here are the final standings:\n");
if(playerscore[0]>playerscore[1])
{
printf("%s %d points\n", name[0], playerscore[0]);
printf("%s %d points\n", name[1], playerscore[1]);
}
else
{
printf("%s %d points\n", name[1], playerscore[1]);
printf("%s %d points\n", name[0], playerscore[0]);
}
return 0;
}
void activeplayerstats( char playername[], int score[currentplayer],
int numlives, int currentplayer) {
printf("%s, you now have %d points and %d lives left.\n",
playername[currentplayer],score[currentplayer],
numlives[currentplayer]);
}
void swapplayers(int numlives,int templives, int currentplayer) {
if (numlives<templives) {
if (currentplayer==0) {
currentplayer=1; }
if (currentplayer==1) {
currentplayer=0; }
}
}
void playround(char name[], int *numlives, int *score, int round){
game3.c:65: conflicting types for `activeplayerstats'
game3.c:18: previous declaration of `activeplayerstats'
game3.c: In function `activeplayerstats':
game3.c:68: subscripted value is neither array nor pointer ]
I USe GCC compiler