Ze DOS command way to change console colors

vegaseat 1 Tallied Votes 283 Views Share

Quick and dirty way to change your console program colors using DOS command "Color BackgroundForeground" where Background is hex 0 = black to F = white, dito for Foreground.

// using ye olde DOS commands to change the console colors
// background colors hex 0 to F
// text or foreground colors hex 0 to F
// experiment and find the combination you like
// a Dev-C++ tested console application by  vegaseat  25mar2005

#include <cstdlib>
#include <iostream>

using namespace std;

int main()
{
  // green text on white
  system("Color F2");
  cout << "Color test, F = white BG  and  2 = green FG" << endl;
  cout << "Press any key ...";
  cin.get();
  // clear the screen
  system("CLS");
  // red text on yellow
  system("Color E4");
  cout << "Color test, E = yellow BG  and  4 = red FG" << endl;
  cout << "Press any key ...";
  cin.get();
  
  return EXIT_SUCCESS;
}