Posted on 1999-07-11
i had written the below simple prog . however i am facing a prob .
the prog is
printf("\n enter the number ");
case '0':printf(" zero "); break;
case '1':printf(" one "); break;
case '9':printf(" nine ");
default: printf(" invalid number");
printf(" want to enter an other num");
the prob is that it is not waiting for me to enter a char after getchar it is directly going to the $ prompt. i think it is the buffer problem. how to clear the buffer. flushall does not work.how to do it with getchar. i then declared ch as string i.e array of 1 char. then it worked just fine.
i am working on sun os 5.6 c version 4.something