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

help with C program



Hi,
I have a small C program wich i compile with GNU C Compiler 2.8.1 and 2.7.
and i got the same result in both times.

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
main()
{
 char str[10];
 int num;
 scanf("%s",str);
 printf("scanf accept %s\n",str);
 num=getchar();
 printf("getchar accept %c\n",num);
}

For some reason "getchat()" accept Null string and do'nt  prompt for the user.
I run  kernel 2.2.3 on pentium 120 with 32MG
I am sure it is somting simple but i just can'nt see it!!
Does anybody have any idea about it?
Thank you