使用ANSI转义字符序列便可以实现。代码如下: printf("\x1b[0;32m hello world 绿 \n\x1b[0m");除此之外,如果你想实现更高级的文本用户界面(TUI),那么可以使用 ncurses 库。