+ 2
When i entered 555 as input.... Why do 5 came out as output?
include <stdio.h> int main() { char a = getchar(); printf("You entered: %c", a); return 0; }
1 Respuesta
+ 5
'getchar' only gets one char.
So basically, only your first entered char lands in a.
If you want to read in more, you need a char array (a place for several chars in a row), and another function that reads more than one char.
char a[10];
scanf("%s", a); // s for string
printf("You entered: %s", a);