'printf' 从整数生成指针而不进行强制转换

hi1*_*i15 2 c printf unsigned

我是一个真正的 C 新手,我正在尝试在 C 中运行以下代码:

#include <stdio.h>
int main()
{
  unsigned long i = 1UL << 2;
  int j = (i==4);
  printf('%d', j);
  return 0;
}
Run Code Online (Sandbox Code Playgroud)

但它给出了错误:

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, ...);
Run Code Online (Sandbox Code Playgroud)

我不确定这里出了什么问题。有什么帮助吗?

Mic*_*ael 7

printf 语句不能使用单引号。尝试这个:

printf("%d", j);
Run Code Online (Sandbox Code Playgroud)