I know "textcolor();" is for C++ and i've seen methods for unix... but is there way for windows also?
#include <stdio.h>
int main()
{
printf("\ntest - C programming text color!");
printf("\n--------------------------------");
printf("\n\n\t\t-BREAK-\n\n");
textcolor(15);
printf("WHITE\n");
textcolor(0);
printf("BLACK\n");
textcolor(4);
printf("RED\n");
textcolor(1);
printf("BLUE\n");
textcolor(2);
printf("GREEN\n");
textcolor(5);
printf("MAGENTA\n");
textcolor(14);
printf("YELLOW\n");
textcolor(3);
printf("CYAN\n");
textcolor(7);
printf("LIGHT GRAY\n");
}
I can't find any anything on the net... let's hope the good people from stack overflow can help :D
C please, not C++
Here you go: http://msdn.microsoft.com/en-us/library/windows/desktop/ms686047(v=vs.85).aspx
You can see one usage of it right here on SO: What do this expression mean? (SetConsoleTextAttribute function in C)
Since you want a C and Windows specific solution, I'd recommend using the
SetConsoleTextAttribute()
function in the Win32 API. You'll need to grab a handle to the console, and then pass it with the appropriate attributes.As a simple example:
For more info on the available attributes, look here.
Hope this helps! :)