0

FYI, I am using C NOT C++ in Xcode I can't use conio.h I want to print text in different colour. Any help is greatly appreciated Methods offered in other posts don't work which is why I have posted it again Thanks

Abhishek
  • 1
  • 2
  • 1
    This question is already answered [here](http://stackoverflow.com/questions/3219393/stdlib-and-colored-output-in-c). –  Nov 24 '13 at 05:28

1 Answers1

0

Using escape code you can do this

#include <stdio.h>

#define COLOR_RESET  "\x1b[0m"
#define COLOR_RED    "\x1b[31m"
#define COLOR_GREEN  "\x1b[32m"

int main()
{
    printf(COLOR_GREEN "Some good text\n");
    printf(COLOR_RED   "Some evil text\n");
    printf(COLOR_RESET "Some normal text\n");

    return 0;
}
Deck
  • 1,969
  • 4
  • 20
  • 41