I have unsigned char variable which stores ASCII code of some symbol (e.g., '1').
I want to print the symbol. Am I using the correct format specifier? Is this well defined? or should I cast it to int inside sprintf?
unsigned char unsignedCharVar = 49;
sprintf(dest,"%c", unsignedCharVar); // should print '1'
printf(and family) reference. - Some programmer dudeunsigned charto store, essentially, characters? And if you want to print the characters as a character then you need to cast the variable to be correct, which might cause UB ifcharis signed and the value is over 127. - Some programmer dudesprintf(dest,"%c", unsignedCharVar); // should print '1'heresprintfdoes not print anything. tryprintf("%s",dest);after yoursprintf. - Jayesh Bhoisprintf. - anon