最佳答案
                                        
                                                                        
                                我有以下计划
#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;
}
当使用 gcc filename.c进行编译时,会发出以下警告(在 scanf()行中)。
warning: format ‘%u’ expects argument of type ‘unsigned int *’, but argument 2 has type ‘short unsigned int *’ [-Wformat]
然后,我引用了 C99 specification - 7.19.6 Formatted input/output functions,当使用长度修饰符(如 short、 long等)和 unsigned来表示 int数据类型时,我无法理解正确的格式说明符。
%u是正确的说明符 unsigned short int吗? 如果是,为什么我得到上述警告? !
编辑:
大多数时候,我正在尝试 %uh,它仍然在发出警告。
 
                                
                             
                                
                             
                                
                            