首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C语言 >

printf("\%d"); 能输出什么?y

2012-08-16 
printf(\%d) 会输出什么?y?请教一下各位网友:C/C++ code#includestdio.h int main(){printf(%d)//

printf("\%d"); 会输出什么?y?
请教一下各位网友:

C/C++ code
#include<stdio.h> int main(){    printf("%d");         //printf("%d\t%d");     return 0;}

我的编译器输出:2008950864
为什么会有输出啊,另外又引出一个问题:如何输出“%d”啊?

请大侠指点迷津!!!谢谢!!

[解决办法]
参数不够:The results are undefined 
If there are more arguments than there are format specifications, the extra arguments are ignored. The results are undefined if there are not enough arguments for all the format specifications.
[解决办法]
"%d"是格式输出符,后面要跟参数,有的编译器在不提供参数是回随机输出,如果非要输出%d
printf("%");
printf("d");
暂时没找到别的办法。
探讨

linux gcc 测试每次输出都不一样。未知结果?

[解决办法]
这种行为是未定义的,可能是任何结果。
[解决办法]
#include<stdio.h> 

int main()
{
printf("%%d"); 
//printf("%d\t%d"); 
return 0;
}

热点排行
Bad Request.