Block Separator in C ++

How to include a separator of units (value 31 in ascii table) in a line other than snprintf()? I want to make it like we usually initialize a string.

eg

char[100] a = "abc"
+5
source share
2 answers

31 in dec = 0x1f in hexadecimal format. Hence,

char x[] = "blah\x1f" "blah";
//              ^^^^ unit separator.

The line is split into two so that the compiler does not read the escape sequence as 0x1fb (it should be read as 0x1f, which is 31 decimal). Alternatively, you can use the octal sequence:

char x[] = "blah\037blah";
//              ^^^^ unit separator.
+11
source

You can do:

char str[] = {'a',31,'b','c',0};
+2
source

All Articles