Why doesnt that code work?

Q

Why doesn't the code
short int s;
scanf("%d", &s);

work?

✍: Guest

A
When converting %d, scanf expects a pointer to an int. To convert to a short int, use %hd .

2015-10-28, 1044👍, 0💬