Code:
#include <stdio.h>
#include<string.h>
char name[100] = {0};
int numlives = 5;
int score = 0;
int round = 1;
int player1lives = 5;
int player1turn = 0;
int player1score = 0;
int player2lives = 5;
int player2turn = 0;
int player2score = 0;
int templives;
void activeplayerstats(void);
void playround(char name[], int* numlives, int*score, int round);
int main(void) {
char name1[100]= {0};
char name2[100]= {0};
printf("Player one, what is your name?\n");
scanf("%s", name1);
printf("Player two, what is your name?\n");
scanf("%s", name2);
strcpy(name,name1);
round = player1turn;
numlives = player1lives;
score = player1score;
while (player1lives>0 || player2lives>0)
{
if (numlives>0)
{
templives=numlives;
playround(char name[], int* numlives, int* score, int round);
}
if (numlives=0)
{
printf("Your Game is Over.\n");
}
activeplayerstats();
swapplayers( &name1, &name2);
;}
}
printf("Here are the final standings:\n");
if(player1score>player2score)
{
printf("%s %d points\n", name1, player1score);
printf("%s %d points\n", name2, player2score);
}
else
{
I get these errors when compiling:
game2.c: In function 'main':
game2.c:38: parse error before "char"
game2.c: At top level:
game2.c:50: parse error before string constant
game2.c:50: warning: conflicting types for built-in function 'printf'
game2.c:50: warning: data definition has no type or storage class
game2.c:54: parse error before string constant
game2.c:54: warning: data definition has no type or storage class
game2.c:59: parse error before sting constant
game2.c:59: warning: data definiton has no type or storage class
game2.c: In function 'activeplayerstats':
game2.c:68: warning: 'swapplayers' was declared
implicitly 'extern' and later 'static'
game2.c:46: warning: previous declaration of 'swapplayers'
game2.c:68: warning: type mismatch with previous implicit
declaration
game2.c:46: warning: previous implicit declaration
of 'swapplayers'
game2.c: In function swapplayers':
game2.c:70: impatible type in assignment
game2.c: In function 'activeplayerstats':
game2.c:75: parse error at end of input