I am currently writing a script as a test to see how hard it would be to make a mini-program on command prompt.
I am new to C programming and I have been using 'C for Dummies'.
I have written this code. Please tell me where I have gone wrong and where I can improve; I hope the annotations help you.
void delay(void); /* prototyping the delay function */
double xp; /* this is the global variable which holds the user's experience acquired */
int x; /* this refers to the 'x' employed at the end of this code */
char target; /* refers to the selection of the monster and the response */
printf("time to kill a monster\n");
printf("select your target:\n");
printf("GOBLIN, RED ONION, GIANT RAT\n");
printf("you are now attacking a %s\n",target);
printf("goblin is killed!\n");
printf("red onion is killed!\n");
printf("giant rat is killed!\n");
void delay() /* the delay function which tells he user the fight is currently underway */
printf("you swing your sword!\n");
printf("looks like you've killed a %s!\n",target);
printf("you currently have %d experience!\n",xp);
printf("would you like to fight another animal?\n",response);
if(response=='Y' || response =='y')
/* need to find a command that tells the compiler to re-run the program, of course remembering the xp acquired */
if(response=='n' || response =='N')
/* need to tell the compiler to end the script if 'n'/'N' is answered */
printf("Pardon? Please give a valid response in a Yes/No format, please.\n");