I tried running the code below and i got an unexpected output
Code:
#include<stdio.h>
void main()
{
char a='A';
while(a)
{
printf("%d\n",a );
a++;
}
printf("%d",a);
getchar();
}
The code is supossed to give an infinite loop but instead it terminates with a=0
I tried running it with some casting like this
Code:
#include<stdio.h>
void main()
{
char a='A';
while((int)a)
{
printf("%d\n",(int)a );
(int)a++;
}
printf("%d",(int)a);
getchar();
}
But the output was the same as before.
Any help on why the code has this unexpected behaviour???