[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

off topic: Doubt about gcc 3.3.3 and ( getchar() or scanf(%s) )?



Hello,

the following code does not work:
"
...
void main(void)
{
  char option;

  printf("Choose an option: ");
  
  option = toupper(getchar());

  printf("Chosse another option: ");

  scanf("%c", &option);

  ...


It shows "Choose an option: Choose another option ". Why?
Whether I put two lines "fflush(stdin)" before the inputs, the same
above occurs.

my gcc: "$ gcc --version
gcc (GCC) 3.3.3 20040412 (Red Hat Linux 3.3.3-7)"

TIA, Vinicius.

P.S.: Where is the best place to put this question, pĺease?


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]