Interview Questions

Why doesnt that code work?

C Interview Questions and Answers


(Continued from previous question...)

Why doesnt that code work?

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

work?

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

(Continued on next question...)

Other Interview Questions