Hello everyone. I have a very basic program which I wrote, to print the integer equivalents of an ASCII character. The code is below:
Code:
#include<stdio.h>
int main(void)
{
char c;
while (1)
{
scanf("%c", &c);
printf("%d\n", c);
}
}
The code is supposed to take a character as input and print the integer equivalent of that character. But the problem is that, after printing the integer equivalent, it prints an extra '10', every time.
My question is: Why does this extra '10' always come? When the code is just a simple:
Code:
#include<stdio.h>
int main(void)
{
char c;
scanf("%c", &c);
printf("%d\n", c);
}
The code works just fine. There is no extra '10' displayed. I am using Ubuntu 9.10 with gcc-4.4.1.
Thanks in advance