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));
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));
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
The string contains two ANSI escape codes. To find out what they mean \x1b[
is denoted by CSI
in the linked article, e.g. \x1b[32m
corresponds to what wikipedia denotes by CSI n m
:
CSI n m
SGR – Select Graphic Rendition
Sets SGR parameters, including text color. After CSI can be zero or more parameters separated with ;. With no parameters, CSI m is treated as CSI 0 m (reset / normal), which is typical of most of the ANSI escape sequences.