I am writing C code for an embedded target, Microchip PIC24, and the runtime libc for some reason won’t properly send \0 values over the serial port.
printf("\xEE\xEE\0test");
for example sends EE EE “test”, the null byte is ignored.
Has anyone a clue why this might be?
EDIT: Ermmm, never mind XD. I was using puts to send over the string.. doh’
A null character is the string terminator in C.
printfstops there because the\0is the end of the string as far as it is concerned. Useputchar(), orprintf()with a format string may work:If you are getting
0xEE 0xEE teston the line as you suggest, are you sure thetestisn’t coming from a differentprintfcall?