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
^@
$
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 ^@
.
Does anyone have ideas about this?
^@
is just how your terminal emulator renders '\0'
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With