0
I have a simple code that converts a char in a int within a loop while, but when I execute and place the first char, the program goes into loop infinite, here comes the code:
#include <stdio.h>
int main()
{
char c;
while (1)
{
printf("Enter a character: ");
if (scanf("%c", &c) == 0)
printf("Err");
printf("The numeric form of %c is %d\n", c, c);
}
return 0;
}
is not the
scanf
that cause infinite loop, is itselfwhile
. Withwhile(1)
how will it exit the loop? 1 will never cease to be 1– Ricardo Pontual