Search code examples
cembeddedembedded-fonts

As I am new to embedded programming I am not able to understand what is "%s\xC2\xB0" ? I know %s is for string


(void)sprintf(Thermo_Buff,"%s\xC2\xB0""",a); //to add to buffer

Solution

  • In string literals, a backslash \ is used as a prefix for special characters. I'm sure you know about newline ("\n") for example.

    If the special character after the backslash is an x then it means that the next two characters are hexadecimal digits, and those two digits are the translated by the compiler into a character.

    In your example the sprintf call adds a string, and then two separate characters based on the hexadecimal numbers 0xc2 and 0xb0, which is UTF-8 for a degree character (see e.g. this reference).