so i am learning c today. I wrote some code to get input with getchar() and save it in a variable to understand how the input to integer works.
So if give a input with my keyboard like "1" and press enter i get a Value of 4910 back. I expected the value of 49 cause the decimal Ascsii code for the Char "1" is 49. Where does the 10 come from?
#include <stdio.h>
/* count lines in input */
main()
{
int c;
while ((c = getchar()) != EOF)
printf("%d",c);
}
10 is the ASCII code of the newline character, '\n'
. You input this character when you hit Enter.