0

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));

Paulo Gasol
  • 83
  • 1
  • 4
  • 2
    Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. – too honest for this site Sep 05 '16 at 11:44

2 Answers2

2

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

1

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.
redneb
  • 21,794
  • 6
  • 42
  • 54