S
SASIKUMAR JP
Hi,
I have written simple code,which will accepts integer input.if i
give character as input,it will not wait for user input next time.what
is the problem in scanf or my code.
Sample Code:
#include <stdio.h>
int main(){
int ch;
while(1){
/* It accepts integer input,if i give character as input,it
will not wait for user input next time */
scanf("%d",&ch)
if(ch == 0){
break;
}
printf("%d",ch);
}
return 0;
}
I have tested this code with Solaris 5.8 with gcc compiler.
Please some one help me to find out problem in code/scanf.
Thanks
Sasikumar
I have written simple code,which will accepts integer input.if i
give character as input,it will not wait for user input next time.what
is the problem in scanf or my code.
Sample Code:
#include <stdio.h>
int main(){
int ch;
while(1){
/* It accepts integer input,if i give character as input,it
will not wait for user input next time */
scanf("%d",&ch)
if(ch == 0){
break;
}
printf("%d",ch);
}
return 0;
}
I have tested this code with Solaris 5.8 with gcc compiler.
Please some one help me to find out problem in code/scanf.
Thanks
Sasikumar