linux c之提示format‘%d’ expects argument of type ‘int’, but argument 2 has type ‘long int’ [-Wformat
生活随笔
收集整理的這篇文章主要介紹了
linux c之提示format‘%d’ expects argument of type ‘int’, but argument 2 has type ‘long int’ [-Wformat
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
1、問題
有個long int data;我輸出的時候printf("data is %d", data);出現(xiàn)下面警告
自己竟然不知道 長整型怎么打印出來,日了狗。
?
2、解決辦法
md,m為指定的輸出字段的寬度。如果數(shù)據(jù)的位數(shù)小于m,則左端補以空格,若大于m,則按實際位數(shù)輸出。
%ld(%mld 也可),輸出長整型數(shù)據(jù)。最后 printf("data is %ld", data)解決。
?
?
?
?
3、總結(jié)
%md,m為指定的輸出字段的寬度。如果數(shù)據(jù)的位數(shù)小于m,則左端補以空格,若大于m,則按實際位數(shù)輸出。
%ld(%mld 也可),輸出長整型數(shù)據(jù)。
u格式符,用來輸出unsigned型數(shù)據(jù),無符號數(shù),以十進制數(shù)形式輸出。格式:%u,%mu,%lu都可希望以后不要犯下這種傻逼錯誤。
?
?
?
總結(jié)
以上是生活随笔為你收集整理的linux c之提示format‘%d’ expects argument of type ‘int’, but argument 2 has type ‘long int’ [-Wformat的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: linux c之strncpy函数和st
- 下一篇: linux c之通过消息队列实现进程通信