在C / C ++中编写非打印字符的行为是什么? [英] What is the behavior of writing a non-printing character in C/C++?

查看:194
本文介绍了在C / C ++中编写非打印字符的行为是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果通过 printf / fprintf ?我很困惑,因为C标准N1570 / 5.2.2中的单词只讨论打印字符和字母转义序列的显示语义。

Is the behavior of writing a non-printing character undefined or implementation-defined, if the character is written via printf/fprintf? I am confused because the words in the C standard N1570/5.2.2 only talks about the display semantics for printing characters and alphabetic escape sequences.

此外,如果字符是通过 std :: ostream (仅限C ++)写的?

In addition, what if the character is written via std::ostream (C++ only)?

推荐答案

ASCII不可打印(控制)字符的输出是实现定义的。

The output of ASCII non-printable (control) characters is implementation defined.

具体来说,解释是输出设备的责任。

Specifically, interpretation is the responsibility of the output device.

编辑1:

输出设备作为文件打开时,可以打开二进制。当以二进制打开时,输出不会被翻译(例如行结尾)。

Edit 1:
When the output device is opened as a file, it can be opened as binary. When opened as binary the output is not translated (e.g. line endings).

这篇关于在C / C ++中编写非打印字符的行为是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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