我知道"textcolor();"是用于C ++的,我也看到了unix的方法... 但是在Windows上有没有方法呢?
#include <stdio.h>
int main()
{
printf("\ntest - C programming text color!");
printf("\n--------------------------------");
printf("\n\n\t\t-BREAK-\n\n");
textcolor(15);
printf("WHITE\n");
textcolor(0);
printf("BLACK\n");
textcolor(4);
printf("RED\n");
textcolor(1);
printf("BLUE\n");
textcolor(2);
printf("GREEN\n");
textcolor(5);
printf("MAGENTA\n");
textcolor(14);
printf("YELLOW\n");
textcolor(3);
printf("CYAN\n");
textcolor(7);
printf("LIGHT GRAY\n");
}
我在网上找不到任何东西......希望来自stack overflow的好心人能够帮助:D
请用C语言,而不是C++。
GetConsoleScreenBufferInfo()
读取原始属性,将其存储在变量中,然后在完成后恢复它们。我已更新答案以显示如何执行此操作。 :) - Miguel