Reputation: 159
I am using Xcode and trying to display colored output to the console. it isn't working and I don't know why, I've looked at other stack overflow posts and tried the code that works. help is appreciated!
#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;
}
Upvotes: 2
Views: 384
Reputation: 7287
You're using VT/ANSI codes. For that to work, make sure you run the application in a terminal window that supports this.
The macOS Terminal app is in the Utilities folder in Applications.
But if you want a smarter way of displaying colors you should use a curses library (like ncurses), as it will detect the right way to display color for the type of terminal you are using to run the application.
Upvotes: 1