How to print #39;#39; instead of a newline?(如何打印 而不是换行符?)
问题描述
我正在编写一个程序,它使用打印其输入的十六进制转储.但是,当传入换行符、制表符等并破坏我的输出格式时,我遇到了问题.
I am writing a program that uses prints a hex dump of its input. However, I'm running into problems when newlines, tabs, etc are passed in and destroying my output formatting.
如何使用 printf(或我猜是 cout)打印 ' ' 而不是打印实际的换行符?我只需要为此做一些手动解析吗?
How can I use printf (or cout I guess) to print ' ' instead of printing an actual newline? Do I just need to do some manual parsing for this?
我正在动态接收我的数据,这不仅仅是我讨厌的 ,而是所有符号.例如,这是我的 printf 语句:
I'm receiving my data dynamically, it's not just the that I'm corned about, but rather all symbols. For example, this is my printf statement:
printf("%c", theChar);
当换行符作为 theChar 传入时,如何打印 但当 theChar 是有效的可打印字符时,它仍然打印普通文本?
How can I make this print when a newline is passed in as theChar but still make it print normal text when theChar is a valid printable character?
推荐答案
打印\n"——\"产生",然后n"被识别为普通符号.如需更多信息,请参阅此处.
Print "\n" – "\" produces "" and then "n" is recognized as an ordinary symbol. For more information see here.
这篇关于如何打印 ' ' 而不是换行符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何打印 ' ' 而不是换行符?


- 静态初始化顺序失败 2022-01-01
- 近似搜索的工作原理 2021-01-01
- 一起使用 MPI 和 OpenCV 时出现分段错误 2022-01-01
- C++ 协变模板 2021-01-01
- STL 中有 dereference_iterator 吗? 2022-01-01
- 与 int by int 相比,为什么执行 float by float 矩阵乘法更快? 2021-01-01
- Stroustrup 的 Simple_window.h 2022-01-01
- 如何对自定义类的向量使用std::find()? 2022-11-07
- 从python回调到c++的选项 2022-11-16
- 使用/clr 时出现 LNK2022 错误 2022-01-01