• Log in or sign up for an account here: https://www.sythe.org/login

Simple C++ Program -- Colored Text

  • Thread starter Thread starter Zeh Progage
  • Start date Start date
Z

Zeh Progage

Guest
Code:
#include <iostream>
using namespace std;

int main(){
    system("Color 0A");
    cout << "I love the colors!\tDon't you?" << endl;
    system("pause");
    return 0;
}

You can play around with the colors, the first character is the background color and the second is the foreground.
The colors:
Code:
0 = Black       8 = Gray
1 = Blue        9 = Light Blue
2 = Green       A = Light Green
3 = Aqua        B = Light Aqua
4 = Red         C = Light Red
5 = Purple      D = Light Purple
6 = Yellow      E = Light Yellow
7 = White       F = Bright White
Also, if you set two colors the same it sets the warning to 1; you can run it but it really won't work to well:p
 
What are you talking about? Its C++ code. The only thing you need to worry about with OS' is if your computer can run a C++ IDE.

Doesn't system() pass the string to the command line? I'm not a C++ expert, hence why I'm unsure, but I would think it depends on whether your OS supports the color command or not.
 
Doesn't system() pass the string to the command line? I'm not a C++ expert, hence why I'm unsure, but I would think it depends on whether your OS supports the color command or not.
It does depend on if the OS supports color or not, and it isn't supported on *nix systems. Oh well, there should be another way to do it in the *nix environment.:D
 
Yep, thanks :) I just wanted some clarification, because I'm just venturing into programming for different operating systems, and it's a zoo.
 
Runescape Gamblingrunescape gambling
Back
Top