I have the following program
#include <stdio.h>
int main(void)
{
unsigned short int length = 10;
printf("Enter length : ");
scanf("%u", &length);
printf("value is %u \n", length);
return 0;
}
Which when compiled using gcc filename.c issued the following warning (in the scanf() line).
warning: format ‘%u’ expects argument of type ‘unsigned int *’, but argument 2 has type ‘short unsigned int *’ [-Wformat]
I then referred the C99 specification - 7.19.6 Formatted input/output functions and couldn't understand the correct format specifier when using the length modifiers (like short, long, etc) with unsigned for int data type.
Is %u the correct specifier unsigned short int? If so why am I getting the above mentioned warning?!
EDIT:
Most of the time, I was trying %uh and it was still giving the warning.