Use string c to send multiple null characters. ASCII Armoring
String Functions C (eg strlen()
, printf()
etc.) assume that the buffer will end with zero. If you have a buffer with multiple 0x00 characters, then you cannot use any functions that treat 0x00 as a null character.
So instead of using, for example, strcpy()
(or strncpy()
), you should use memcpy()
- to move bytes of memory from one location to another, instead of relying on this null-terminated behavior.
source to share
String C is just an array of null-terminated characters. However, if you consider it as an array, it can contain internal null characters:
char data[4] = { 'x', '\0', 'y', '\0' };
However, you have to be careful, as most of the standard library functions will not work as they expect the C string to end with the first null character.
For example, strlen(data)
will return 1 in the example above, since it stops after the first null character.
source to share