I need to concatenate some strings, and I need to include NULL bytes. I don't want to treat a '\0' as a terminating byte. I want to save my valuable NULL bytes!
In a code example, if
char *a = "\0hey\0\0";
I need to printf in a format that will output "\0hey\0\0".
-AUstin
How about:
int i;
for(i = 0; i < 4; i++)
printf("%c", a[i]);
If you want a 'printf-like' function to use this when you specify %s
in a format string you could include the above code in your own function. But as @Neil mentioned, you'll struggle finding an alternative to looking for null bytes to determine the length of strings. For that I guess you could use some kind of escape character.
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