C中的彩色输出

这里有点新手。这似乎是一个重复的问题,因为其他人提出了这个问题。但是,当我尝试建议的答案时,它对我不起作用,请问为什么。 所以我必须更改输出的颜色,这些是我发现的:

#include <stdio.h>
void red () {
printf("\033[1;31m");

}

void yellow ()
{
 printf("\033[1;33m");
}

void reset () {
  printf("\033[0m");
}

int main () {
  red();
  printf("Hello ");
  yellow();
  printf("world\n");
  reset;
  return 0;
}

打印出来

[1;31mHello [1;33mworld

作为答案,我也发现了这个

#include <stdio.h>

#define ANSI_COLOR_RED     "\x1b[31m"
#define ANSI_COLOR_GREEN   "\x1b[32m"
#define ANSI_COLOR_YELLOW  "\x1b[33m"
#define ANSI_COLOR_BLUE    "\x1b[34m"
#define ANSI_COLOR_MAGENTA "\x1b[35m"
#define ANSI_COLOR_CYAN    "\x1b[36m"
#define ANSI_COLOR_RESET   "\x1b[0m"

int main (int argc, char const *argv[]) {

  printf(ANSI_COLOR_RED     "This text is RED!"     ANSI_COLOR_RESET "\n");
  printf(ANSI_COLOR_GREEN   "This text is GREEN!"   ANSI_COLOR_RESET "\n");
  printf(ANSI_COLOR_YELLOW  "This text is YELLOW!"  ANSI_COLOR_RESET "\n");
  printf(ANSI_COLOR_BLUE    "This text is BLUE!"    ANSI_COLOR_RESET "\n");
  printf(ANSI_COLOR_MAGENTA "This text is MAGENTA!" ANSI_COLOR_RESET "\n");
  printf(ANSI_COLOR_CYAN    "This text is CYAN!"    ANSI_COLOR_RESET "\n");

  return 0;
}

打印出来

[31mThis text is RED![0m
[32mThis text is GREEN![0m
[33mThis text is YELLOW![0m
[34mThis text is BLUE![0m
[35mThis text is MAGENTA![0m
[36mThis text is CYAN![0m

所以它不会改变任何颜色,只是将它们原样打印出来...为什么会发生这种情况以及如何为输出着色?