简体   繁体   中英

What do these signs mean? ^@

I compiled c program with this code

printf("|%5c|", '\0'); width 5 is just for example

then used cat -e on a.out

./a.out | cat -e

and have this on the output

| ^@|$

Am i right that it is '\0' represented as ^@? What is it and how does it work?

The ^ (control) symbol represents subtraction of 64 from an ASCII value (or maybe more accurately, clearing of the sixth and seventh bits, but it's the same thing for values between 64 and 95). For example, "A" is 65, and ^A is 1. M is 77, and ^M is 13. "@" is 64, so ^@ is a way of writing character 0.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM