c - Not handling functions right -


my code supposed make simple menu change armor of character. code is:

#include <stdio.h> #include <string.h>  struct armor {    char chestplate [50];    char helmet [50]; };  void changearmor (){     struct armor character;     char [50];     printf("choose chestplate\n");     scanf("%s",&a);     strcpy(character.chestplate,a);     printf("choose helmet\n");     scanf("%s",&a);     strcpy(character.helmet,a);     menu(); }  void checkarmor () {     struct armor character;     printf("your equipped chestplate is: %s\n", character.chestplate);     printf("your equipped helmet is: %s\n", character.helmet);     menu(); }  void menu () {     int a;     printf("what want do?\n");     printf("1.change armor.\n");     printf("2.check current armor.\n");     printf("3.quit\n");     scanf("%d",&a);     if(a==1) changearmor;   // oops: should changearmor();     if(a==2) checkarmor;    // oops: should checkarmor();     if(a!=3) menu;          // oops: maybe should menu(); — or … }  void initializechar (){     struct armor character;     strcpy(character.chestplate, "shirt");     strcpy(character.helmet, "hat"); }  int main () {     struct armor character;     initializechar();     menu();     return 0; } 

when try use on menu, program exits, instead of running function called. there have been doing wrong in code?

edit: parenthesis. thanks.

i guess forgot () meaning changearmor() , checkarmor() functions.

so, when make choice not doing , continues until reaches return 0.


Comments

Popular posts from this blog

javascript - How to get current YouTube IDs via iMacros? -

c# - Maintaining a program folder in program files out of date? -

emulation - Android map show my location didn't work -