没有'\ n'或endl的C ++输出字符串将在字符串末尾输出'#' [英] C++ output string without '\n' or endl will output '#' in the end of string
本文介绍了没有'\ n'或endl的C ++输出字符串将在字符串末尾输出'#'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在ubuntu16.04上,我使用g ++编译此类代码:
On ubuntu16.04, I use g++ to compile such code:
#include <iostream>
int main()
{
std::cout << "Hello World!";
return 0;
}
如果字符串不以'\ n'结尾或最后不使用'std :: endl',则输出为 Hello World!#
我不知道为什么它以结尾'#'
if the string does not end with '\n' or use 'std::endl' at the last, the output will beHello World!#
I don't know why it ends with '#'
推荐答案
不是,这是您的bash提示.
It doesn't, it's your bash prompt.
您可以使用 echo
重现您的问题:
You can reproduce your problem with echo
:
# echo "Hello, World!"
Hello, World!
# echo -n "Hello, World!"
Hello, World!#
这篇关于没有'\ n'或endl的C ++输出字符串将在字符串末尾输出'#'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文