whats wrong with this code i have?

This is a discussion on whats wrong with this code i have? within the Game Programming forums, part of the General Programming Boards category; Code: #include <stdio.h> #include<string.h> char name[100] = {0}; int numlives = 5; int score = 0; int round = 1; ...

  1. #1
    Registered User
    Join Date
    Sep 2003
    Posts
    56

    whats wrong with this code i have?

    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

  2. #2
    Pursuing knowledge confuted's Avatar
    Join Date
    Jun 2002
    Posts
    1,916
    Code:
    swapplayers( &name1, &name2);
    
           ;}
          }
       printf("Here are the final standings:\n");
    I think the problem is that you have an extra brace and semi-colon, no?
    Away.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. what is wrong in this simple code
    By vikingcarioca in forum C Programming
    Replies: 4
    Last Post: 04-23-2009, 07:10 AM
  2. what is wrong with this code please
    By korbitz in forum Windows Programming
    Replies: 3
    Last Post: 03-05-2004, 09:11 AM
  3. I cant find what is wrong with this code
    By senegene in forum C Programming
    Replies: 1
    Last Post: 11-12-2002, 05:32 PM
  4. Anyone see what is wrong with this code?
    By Wise1 in forum C Programming
    Replies: 2
    Last Post: 02-13-2002, 01:01 PM
  5. very simple code, please check to see whats wrong
    By Unregistered in forum C Programming
    Replies: 3
    Last Post: 10-10-2001, 12:51 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21