#include <stdio.h>
int main (int argc, const char * argv[]) {
char i, j;
printf("type a letter:");
scanf("%c", &i);
switch (i) {
case 'f':
printf("type a new letter:");
scanf("%c", &j);
switch (j) {
case 'm':
printf("welldone");
break;
case 'n':
printf("try again");
break;
}
break;
case 'b':
printf("bye");
break;
}
return 0;
}
And here is what comes out in the console when I run this program :
/[Session started at 2011-02-26 21:31:00 +0200.]
GNU gdb 6.3.50-20050815 (Apple version gdb-1472) (Wed Jul 21 10:53:12 UTC 2010)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "x86_64-apple-darwin".tty /dev/ttys000
Loading program into debugger…
Program loaded.
run
[Switching to process 335]
Running…
type a letter:f
type a new letter:
Debugger stopped.
Program exited with status value:0./
As you can see , when I type the letter 'f' the program prompts me to type a new letter and then ends without waiting for me to type it and print the string. Why is it happening and how could I make this work ?
Thank you very much !!!
Mod edit - Please

New Topic/Question
Reply




MultiQuote




|