Search code examples
cformatspecifier

Complex format specifier C


Can someone explain me what king of specifier is in the below code? and give me an example.

printf("\r\x1b[32mConverting: \x1b[36m%d\x1b[0m",(Convert));


Solution

  • These ascii special codes are used to color debug messages. \x1b[32m gives green color to "convering" \x1b[36m%d gives cyan color to the Convert integer and \x1b[0m%d finally resets the color values. \r is carriage return

    %d is nothing but the format specifier for integers https://www.quora.com/What-does-d-mean-in-the-C-programming-language