红联Linux门户
Linux帮助

linux c之提示format‘%d’ expects argument of type ‘int’

发布时间:2017-02-17 10:34:20来源:linux网站作者:改变自己chenyu
1、问题
有个long int data;我输出的时候printf("data is %d", data);出现下面警告:
linux c之提示format‘%d’ expects argument of type ‘int’
format‘%d’ expects argument of type ‘int’, but argument 2 has type ‘long int’ [-Wformat=] printr("rcv data msg_type is%d\n", data.msg_type);
 
2、解决办法
md,m为指定的输出字段的宽度。如果数据的位数小于m,则左端补以空格,若大于m,则按实际位数输出。
%ld(%mld 也可),输出长整型数据。
最后 printf("data is %ld", data)解决。
 
3、总结
%md,m为指定的输出字段的宽度。如果数据的位数小于m,则左端补以空格,若大于m,则按实际位数输出。
%ld(%mld 也可),输出长整型数据。
u格式符,用来输出unsigned型数据,无符号数,以十进制数形式输出。格式:%u,%mu,%lu都可。
 
本文永久更新地址:http://www.linuxdiyf.com/linux/28480.html