Debugging my c program, number guessing game -


i need debugging program , don't know wrong. using putty , vi editor run program. code:

#include <stdio.h> #include <time.h> #include <stdlib.h> #include <malloc.h>  int main(void) {       int playernumber = 0;     int number = 0;     int playerinput = 0;         int guess = 0;     char input;     char str[6] = {0};     int playera = 0;     int playerb = 0;     int passa = 3;     int passb = 3;     int = 0;     int playerturn = 0;       srand(time(null));     playernumber = 1 + rand() % 2; /* random number generated */      printf("\nplayer %d goes fist\n", playernumber);      printf("player number?\n");         while (playernumber != playerinput) {         scanf("%d", &playerinput);          if (playernumber != playerinput) printf("you have wait turn.\nplayer number?\n");          playernumber = playera;          if (playera = 1) playerb = 2;         else playerb = 1;          srand(time(null));         number = 0 + rand() % 100; /* random number generated */          printf("enter guess, 0 - 100 or pass: "); /* input guess */          while(number != guess) {          for(i = 1; < 1000; i++) {             if (i%2 == 1) playerturn = playera;             else playerturn = playerb;             scanf("%s", str);              if (strcmp(str, "pass") == 0) printf("player number?\n");             else {                 guess = atoi(str);                 if(guess < number) /* if guess lower, output: guess low */                     printf("your guess low.\n player number:\n ");                  else if(guess > number) /* if guess higher, output: guess high */                     printf("your guess high.\n player number:\n ");                  else /* guess equial random number: success!! */                     printf("yes!! got it!\n");                 return 0;             }         }     } } 

}

this error: project2total.c: in function main': project2total.c:49: error:playerturn' undeclared (first use in function) project2total.c:49: error: (each undeclared identifier reported once project2total.c:49: error: each function appears in.)

c case-sensitive. in function, there no playerturn declared, seem have declared playerturn. correcting upper-case p lower-case work, assuming variable want refer to. :)


Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -