What I'm doing is 100% correct. I know using (int) is the official way
in C. But this is supposed to work too. as the char 'a' == int 97
Anyways I've found a workaround,
here is the modified code
#include<stdio.h>
int main()
{
char a;
while(1)
{
scanf("%c",&a);
if(a!='\n')
printf("%d\n",a-96);
}
return 0;
}
The problem here is that 'return' ascii value 10 remains in the input
buffer stream. So in the next iteration the loop just skips scanf() as
it takes input from the stream.
So the user get to input again in the third iteration. Sound good at
the face of it but it doesn't work if I use fflush(stdin);
On Turbo C back in college I had similar issues with getche(); and
flushall(); did the trick there. But I can't seem to get rid of it in
GCC.