C的输出问题 [英] C output question

查看:135
本文介绍了C的输出问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么它的输出%% ??

 #包括LT&;&stdio.h中GT;
INT主要(无效)
{
        的printf(%%% \\ n);
返回0;
}


解决方案

这是不确定的行为,绝对的任何的可能发生。 C99第7.19.6.1/9规定:


  

如果一个转换说明是无效的,其行为是不确定的。


和没有preceding部分允许空间的转换说明。它们仅限于从字符集 diouxXfFeEgGaAcsPn%

Why its output is %%??

#include<stdio.h>
int main(void)
{
        printf("% % %\n");
return 0;
}

解决方案

It's undefined behaviour and absolutely anything can happen. Section 7.19.6.1/9 of C99 states:

If a conversion specification is invalid, the behavior is undefined.

and none of the preceding sections allow a conversion specifier of a space. They are limited to characters from the set diouxXfFeEgGaAcsPn%.

这篇关于C的输出问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆