What printf format should I use for a typedef like size_t when I don't know whether it is long or some other type?
C Interview Questions and Answers
(Continued from previous question...)
What printf format should I use for a typedef like size_t when I don't know whether it is long or some other type?
Use a cast to convert the value to a known, conservatively-sized type, then use the printf format matching that type. For example, to print the size of a type, you might use
printf("%lu", (unsigned long)sizeof(thetype));
(Continued on next question...)
Other Interview Questions
|