-8

I don't understand what is wrong with this C code. I am just asking this for learning purposes. I know the game is kind of stupid but it's just for fun and learning.

#include <stdio.h>
int main(){
    int response
    char name [20];
        printf ("Welcome to Game1\n");
        printf ("What's your name?\n");
        scanf ("%s",name);
        printf ("From now on you're Private %s\n",name);
        printf ("Loading...\n");
        delay(4000);
        printf("You are in a army excersize yard.\n");
        delay(4000);
        printf("Your sargeant approaches.\n");
        printf ("Sargeant Sam: Drop and give me twenty, Private %s\n",name);
        printf ("1) Yessir!\n2)Make me\n");
        scanf ("%d\n", response);
            if(response==1){
                printf ("You do 20 pushups\n");
            }
            if(response==2){
            printf("Sargeant Sam: What did you say?!\n");
            }
return (0);
} 

These are the errors

game1.c: In function ‘main’:
game1.c:4: error: nested functions are disabled, use -fnested-functions to re-enable
game1.c:4: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘char’
game1.c:16: error: ‘response’ undeclared (first use in this function)
game1.c:16: error: (Each undeclared identifier is reported only once
game1.c:16: error: for each function it appears in.)

I am a complete beginner so please explain everything simply.

Kara
  • 6,115
  • 16
  • 50
  • 57
user2607534
  • 211
  • 3
  • 4
  • 9
  • 1
    Please stop it man, please put some efforts to learn before repeatedly post same question. for example you have just posted a [question-2](http://stackoverflow.com/questions/17793445/what-does-undefined-symbols-for-architecture-x86-64-mean-in-c) before that [qestion-2](http://stackoverflow.com/questions/17792702/when-compiling-a-c-program-i-get-this-error-hello-no-such-file-or-directory) – Grijesh Chauhan Jul 22 '13 at 17:36

2 Answers2

4
int main(){
 int response
             ^

missing semicolon here.

ouah
  • 142,963
  • 15
  • 272
  • 331
3
    int response

A declaration ends with a semicolon: ;.

Besides, there is a lack of coherent indentation and delay doesn't belong to C standard (not declared in <stdio.h>).

md5
  • 23,373
  • 3
  • 44
  • 93
  • 1
    Other post beat you by 15 seconds – jdero Jul 22 '13 at 17:35
  • sorry that was a terrible post:( sorry for wasting your time. i cant post anything now because my score is low. now i have a good question that i already researched a lot so please make this higher. – user2607534 Jul 23 '13 at 15:23