简体   繁体   中英

How to write ascii symbol into char table?

Let's assume that I've got such a table:

char *table = "abcdef\n";

How can I put '\\n' as decimal subsituide (eg. in hex I put \\x0D, in oct I put \\015, but what about decimal?)

'/n' is not a character control, but a multi-character constant, so I assume you're talking about '\\n' instead.

There is no escape notation in decimal, so simply use \\n , the octal ( \\012 or \\12 ) or the hexadecimal ( \\x0a ) escape notation.

Learn more about escape sequences .

Or you can define one Macro #define NEW_LINE "\\n" . then use char *table = "abcdef"NEW_LINE; And if you cout <<table; out put will be:

abcdef
_

It means the value of table is "abcdef\\n"

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