I'm learning C language by myself.
I wrote the following code and executed it.
Unexpectedly the "first" variable was 0, though I inputted 4.
Could you explain me why this happens and how to fix this?
Code:
#include <stdio.h>
#include <stdint.h>
int main(void) {
int8_t first;
printf("Fist parameter:");
scanf("%d", &first);
int8_t second;
printf("Second parameter:");
scanf("%d", &second);
printf("%d * %d == %d\n", first, second, first * second);
return 0;
}
Expected:
Fist parameter:4
Second parameter:5
4 * 5 == 20
Actual:
Fist parameter:4
Second parameter:5
0 * 5 == 0