I'm trying to replicate some printf
functionality for education purposes, but I've encountered some printf
behavior that I'm unable to understand. I'll try explaining with a simple example:
have this call:
printf(" %c %c %c", 0, 1, 2); // yes, parameters are ints not chars.
The output seems normal, only 3 spaces, numbers are ignored.
But taking printf
output to a file, then using "cat -e file" does this:
^@ ^A ^B
^@ for 0, ^A for 1, ^B for 2 and so on.
Here is my question, what are those symbols? How they relate to the values?
Also my own printf
, does this as well except for the 0 which is treated as a '\0' char...I need to mimic printf
exactly so I need to understand what is going on there...
I've searched about those symbols, but can't find anything. They are not memory garbage because the results are always same.