A
Alexo
hello everyone,
consider my simple example:
/* code starts here */
#include <stdio.h>
int main(void){
int a = 0, b = 0;
do{
printf("\ninsert an integer number ");
b = scanf("%d", &a);
}while( b != 1 );
printf("\nThe number inserted is %d", a);
return 0;
}
/* code ends here */
try to execute it inputing a character instead of an integer number. The
loop never ends.
I would like that the loop be executed only once when the scanf fails.
Thank you in advance
consider my simple example:
/* code starts here */
#include <stdio.h>
int main(void){
int a = 0, b = 0;
do{
printf("\ninsert an integer number ");
b = scanf("%d", &a);
}while( b != 1 );
printf("\nThe number inserted is %d", a);
return 0;
}
/* code ends here */
try to execute it inputing a character instead of an integer number. The
loop never ends.
I would like that the loop be executed only once when the scanf fails.
Thank you in advance