...

View Full Version : Colored Output in C++



jmac555
11-16-2008, 12:06 AM
I was recently writing a program for windows that implemented a colored output, done with code:



void setcolor(unsigned short color) //The function that you'll use to
{ //set the colour
HANDLE hcon = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(hcon,color);
}


now i plan to port this program across to Macintosh using xCode but there doesn't appear to be an include file that allows me to do so.
Any suggestions?

b.t.w my include files


#include <iostream>
#include <time.h>
#include <cstdlib>
#include <windows.h>

oracleguy
11-16-2008, 12:13 AM
SetConsoleTextAttribute is a Windows API call and as such won't exist elsewhere. In order to change the color of a Unix terminal, you need to send terminal commands. They just go in the output, the terminal recognizes them and will let you change the color.

jmac555
11-17-2008, 03:41 AM
whats is the command that you have to send to the terminal?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum