fork download
  1. #include <stdio.h>
  2. int character_game(char correct_answer, int max_guesses){
  3.  
  4. char guessed_char;
  5. int correct_case = 0;
  6. int guessed_case = 0;
  7. int guessed_char_interval1, guessed_char_interval2;
  8.  
  9. do {
  10. printf("letter?\n");
  11. scanf(" %c", &guessed_char);
  12.  
  13. printf("guessed_char is: %d\n", guessed_char);
  14. printf("correct_answer is: %d\n", correct_answer);
  15. printf("guessed character is lower character? 0:no. Else:Yes. (%d)\n", islower(guessed_char));
  16.  
  17. printf("guessed letter is %c\n", guessed_char);
  18. if (guessed_char < correct_answer){
  19. printf("too low\n");
  20. }
  21.  
  22. else if (guessed_char > correct_answer){
  23. printf("too high\n");
  24. }
  25. else if (guessed_char == correct_answer){
  26. if (islower(guessed_char)){
  27. guessed_case = 1;
  28. }
  29. if ( islower(correct_answer)){
  30. correct_case = 1;
  31. }
  32. if (guessed_case == correct_case){
  33. return 1;
  34. }
  35. else{
  36. printf("wrong case\n");
  37. }
  38.  
  39. }
  40.  
  41. max_guesses--;
  42. printf("max_guesses now: %d\n", max_guesses);
  43. }while (max_guesses > 0);
  44. //} ----> Missing
  45.  
  46. int main(void) {
  47. return 0;
  48. }
  49.  
Compilation error #stdin compilation error #stdout 0s 2288KB
stdin
Standard input is empty
compilation info
prog.c: In function ‘character_game’:
prog.c:15:45: warning: implicit declaration of function ‘islower’ [-Wimplicit-function-declaration]
                                             printf("guessed character is lower character? 0:no. Else:Yes. (%d)\n", islower(guessed_char));
                                             ^
prog.c:46:5: warning: ‘main’ is normally a non-static function [-Wmain]
 int main(void) {
     ^
prog.c:48:1: error: expected declaration or statement at end of input
 }
 ^
prog.c:7:31: warning: unused variable ‘guessed_char_interval2’ [-Wunused-variable]
   int guessed_char_interval1, guessed_char_interval2;
                               ^
prog.c:7:7: warning: unused variable ‘guessed_char_interval1’ [-Wunused-variable]
   int guessed_char_interval1, guessed_char_interval2;
       ^
prog.c:48:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
stdout
Standard output is empty