我真的很新的C和我試圖運行下面的代碼在C:「printf」式時將整數指針不進行強制轉換
#include <stdio.h>
int main()
{
unsigned long i = 1UL << 2;
int j = (i==4);
printf('%d', j);
return 0;
}
但它給人的錯誤:
prog.c: In function 'main':
prog.c:6:10: warning: multi-character character constant [-Wmultichar]
printf('%d', j);
^
prog.c:6:10: warning: passing argument 1 of 'printf' makes pointer from integer without a cast [-Wint-conversion]
In file included from prog.c:1:0:
/usr/include/stdio.h:362:12: note: expected 'const char * restrict' but argument is of type 'int'
extern int printf (const char *__restrict __format, ...);
我不知道這裏有什麼問題。任何幫助?
單引號。使用雙引號表示字符串「%d」。 – phoxis