Getting error saying that my program has crashed in C even though it show no issue with the syntax -


i confused why program keeps on crashing. using code blocks, open source ide.

here code:

int main() {   int age;   char gender;    printf("what age?\n");   scanf(" %d", age);    printf("what gender? \(m/f)\n");   scanf(" %c", gender);    if (age>=18){     printf("access granted! please proceed\n");      if (gender == 'm'){       printf("what's dude?");     };     if (gender == 'f'){         printf("how's going dudette?");     };   };   if (age<18){     printf("access denied. please on life.\n");   };    return 0; } 

scanf requires pointer variable you're setting. so, need do:

scanf(" %d", &age); 

and similar gender


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -