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
Asked
Active
Viewed 590 times
1 Answers
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