0

有人可以解释一下下面代码中的说明符之王是什么吗?并举个例子。

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

4

2 回答 2

2

这些 ascii 特殊代码用于为调试消息着色。\x1b[32m 为“转换”提供绿色 \x1b[36m%d 为转换整数提供青色, \x1b[0m%d 最后重置颜色值。\r 是回车

%d 只不过是整数的格式说明符 https://www.quora.com/What-does-d-mean-in-the-C-programming-language

于 2016-09-05T11:19:20.907 回答
1

该字符串包含两个ANSI 转义码。要找出它们的意思,在链接的文章\x1b[中用 表示CSI,例如\x1b[32m对应于维基百科用 表示的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.
于 2016-09-05T11:14:42.740 回答