#define FORMAT "%s ! c is cool \n!"然后 printf(FORMAT,FORMAT);运行结果为什么是%
下面的程序的运行结果为什么是这样呢?求大神知道!
#include<stdio.h>
#define FORMAT "%s ! c is cool \n!"
int main(void)
{ printf(FORMAT,FORMAT); return 0;
}
运行结果:
%s !c is cool!
! c is cool!
printf (FORMAT,FORMAT);等于
printf ( "%s! C is cool!\n", "%s! C is cool!\n");
然后将第一个%s用"%s! C is cool!\n"代替,也就是打印
%s! C is cool!\n! C is cool!\n,即:
%s! C is cool!
! c is cool!