我正在使用Xcode,并尝试将彩色输出显示到控制台。它不工作,我不知道为什么,我已经看了其他堆栈溢出帖子,并尝试了代码的工作。感谢您的帮助!
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define ANSI_COLOR_RESET "\x1b[0m"
#define ANSI_COLOR_CYAN "\x1b[36m"
void dispWrongs(char guess, int wordLength);
int main(void) {
srand(time(NULL)); //sends a "seed" for random number generation
printf(ANSI_COLOR_CYAN " _ _ \n");
printf(ANSI_COLOR_CYAN " ___ ___ _ _ _ __ | |_ _ __(_) ___ ___ \n");
printf(ANSI_COLOR_CYAN " / __/ _ \\| | | | '_ \\| __| '__| |/ _ \\/ __\\ \n");
printf(ANSI_COLOR_CYAN "| (_| (_) | |_| | | | | |_| | | | __/\\__ \\ \n");
printf(ANSI_COLOR_CYAN " \\___\\___/ \\__,_|_| |_|\\__|_| |_|\\___||___/"ANSI_COLOR_RESET"\n");
return 0;
}发布于 2020-06-29 15:38:52
您使用的是VT/ANSI代码。要使其正常工作,请确保在支持此功能的终端窗口中运行应用程序。
macOS终端应用程序位于应用程序中的实用程序文件夹中。
但是,如果您想要一种更智能的显示颜色的方式,您应该使用curses库(如ncurses),因为它会检测到针对运行应用程序所使用的终端类型显示颜色的正确方式。
https://stackoverflow.com/questions/62630525
复制相似问题