空终止字符之差(\\ 0)和`^ @` [英] Difference between null terminated char (\0) and `^@`
本文介绍了空终止字符之差(\\ 0)和`^ @`的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的codeS是这样的:
My codes are like this:
#include <iostream>
using std::cout;
using std::endl;
int main(int argc, char *argv[])
{
cout << (int)('\0') << endl;
cout << (char)(0) << endl;
return 0;
}
我预计在终端看到像这样的:
I expected to see in terminal like this:
$ test-program
0
$
不过,我所看到的是这样的:
However, what I saw is like this:
$ test-program
0
^@
$
是什么让我困惑的是,我觉得'\\ 0'
可转换为 0
。和 0
,也可以浇铸到 \\ 0
。我期望看到一个空字符遵循的 ENDL
,但结果是很奇怪像 ^ @
。
What makes me confusing is that I think '\0'
can be converted to 0
. And 0
can also be casted into \0
. I expected to see a null char followed with a endl
, but the result is something weird like ^@
.
有没有人有这个想法?
推荐答案
^ @
只是你的终端仿真器是如何呈现'\\ 0'
。
^@
is just how your terminal emulator renders '\0'
.
这篇关于空终止字符之差(\\ 0)和`^ @`的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文