i'm wrting a basic C program which the user "talks" to the program, you know the sort. well my main menu looks like this:
int main()
{ char name[50];
char mood;
printf("hey there, .. whats your name?\n");
gets(name);
printf("%s is it? Well how are you today?\n a.Good\n b.Ok\n c.Bad\n", name);
scanf("%c", &mood);
switch(mood)
{
case 'a' : getnum(); break;
case 'c' : bad(); break;
case 'b' : printf("aw, cool \n"); break;
default : printf("please choose good bad or ok in lower case 'cause i'm lazy\n");
}
return 0;
}
that works fine, asks the persons name, displays their input, then goes to the menu. the switch on this works and if you chose a. then it goes to the sum function
void getnum()
{
int num;
printf("yay! me too! want to do a sum? enter a number: ");
scanf("%d", &num);
printf("%d squared is %d\n", num, square(num) );
printf("nice chatting to ya!\n");
}
if you chose c. (bad) it goes to the bad file, prints the "reply oh no, want to tell me about it? Y or N?\n". now after that i've tried manya differnet techniques to scan the input (as it did for the previous questions), from scanf then a switch. to fgets and using a if.. else statement.. but it always cuts out and finishes, completly ignores the next part of the coding.
a different program i wrote (using coding out of a book) using switch statements had the same problem, just stops after the first or second input, anyone know why? i've tried using a cast to convert the character entered to interger (ASCII value) then using an IF statement, but it still won't give a space to read the input, just flies straight through back to c:\documents and settings etc. (this is all run through the command prompt.
is the answer staring me in the face?