复杂格式说明符 C
Complex format specifier C
谁能解释一下下面代码中的说明符之王是什么?并举个例子。
printf("\r\x1b[32mConverting: \x1b[36m%d\x1b[0m",(Convert));
字符串包含两个ANSI escape codes。要找出它们的意思,\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.
这些 ascii 特殊代码用于为调试消息着色。
\x1b[32m 为 "convering" 赋予绿色
\x1b[36m%d 为 Convert 整数提供青色
\x1b[0m%d 最终重置了颜色值。
\r 是回车 return
%d 只是整数的格式说明符
https://www.quora.com/What-does-d-mean-in-the-C-programming-language
谁能解释一下下面代码中的说明符之王是什么?并举个例子。
printf("\r\x1b[32mConverting: \x1b[36m%d\x1b[0m",(Convert));
字符串包含两个ANSI escape codes。要找出它们的意思,\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.
这些 ascii 特殊代码用于为调试消息着色。 \x1b[32m 为 "convering" 赋予绿色 \x1b[36m%d 为 Convert 整数提供青色 \x1b[0m%d 最终重置了颜色值。 \r 是回车 return
%d 只是整数的格式说明符 https://www.quora.com/What-does-d-mean-in-the-C-programming-language