MISRA C : 2004标准限制了程序中使用printf()函数的方式,为保持符合标准,有以下几种替代方案:
char buf[100];
snprintf(buf, sizeof(buf), "The value of x is %d", x);
puts("The value of x is:");
fputs(x, stdout);
FILE *fp = fopen("output.txt", "w+");
fprintf(fp, "The value of x is %d", x);
fclose(fp);
注意:所有这些替代方案都需要包含头文件