problems programe to stop working

0 Maneh Clovis · May 7, 2015
hi guys!
when i type this code in codeblocks then run it a message comes up saying program stop working.


int main()
{
    int age;
    char gender,name;
    printf("what is you name?\n");
    scanf(" %s",name);

 printf("what is your gender m/f?\n");
    scanf("%s",gender);

    printf(" how old are you? \n ");
    scanf("%d",age);



    if( age >=18);
     printf(" %s you are welcome" );

    return 0;
}



Post a Reply

Replies

Oldest  Newest  Rating
0 Saurabh Apte · June 1, 2015
Use scanf("%d", &age) 
0 Suraj Gautam · May 11, 2015
Put %s sign after scanf(" %d", &age);
I think this will solve your problem. Also put space after " in " %d". Bucky told me about it in his tutorial.
Cheers
0 c student · May 8, 2015
scanf ("%d", &age);

also:

char gender, name;   /* declared char */

but used:

scanf(" %s",name);   /* used string with char */

and

scanf("%s",gender);   /* used string with char */
  • 1

C

107,193 followers
About

One of the most popular languages of all time.

Links
Moderators
Bucky Roberts Administrator