Simple C++ Program -- Colored Text

Discussion in 'Programming General' started by Zeh Progage, Aug 13, 2007.

Simple C++ Program -- Colored Text
  1. Unread #1 - Aug 13, 2007 at 4:03 AM
  2. Zeh Progage
    Referrals:
    0

    Zeh Progage Guest

    Simple C++ Program -- Colored Text

    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
     
  3. Unread #2 - Aug 13, 2007 at 4:08 AM
  4. kingdom
    Joined:
    Jan 22, 2007
    Posts:
    236
    Referrals:
    0
    Sythe Gold:
    0

    kingdom Active Member
    Banned

    Simple C++ Program -- Colored Text

    So make it to work well ;)
     
  5. Unread #3 - Aug 13, 2007 at 4:14 AM
  6. Zeh Progage
    Referrals:
    0

    Zeh Progage Guest

    Simple C++ Program -- Colored Text

    When I said that I was talking about if you made both colors the same :p
     
  7. Unread #4 - Aug 13, 2007 at 2:31 PM
  8. Zyloch
    Joined:
    Apr 21, 2005
    Posts:
    63
    Referrals:
    0
    Sythe Gold:
    0

    Zyloch Member

    Simple C++ Program -- Colored Text

    This is Windows 2000+ only?
     
  9. Unread #5 - Aug 13, 2007 at 2:44 PM
  10. timk777
    Joined:
    Feb 19, 2007
    Posts:
    156
    Referrals:
    0
    Sythe Gold:
    0

    timk777 Active Member

    Simple C++ Program -- Colored Text

    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.
     
  11. Unread #6 - Aug 13, 2007 at 3:09 PM
  12. Zeh Progage
    Referrals:
    0

    Zeh Progage Guest

    Simple C++ Program -- Colored Text

    I think it'd work on any OS because I never made any API calls from windows :)
     
  13. Unread #7 - Aug 14, 2007 at 4:08 AM
  14. Zyloch
    Joined:
    Apr 21, 2005
    Posts:
    63
    Referrals:
    0
    Sythe Gold:
    0

    Zyloch Member

    Simple C++ Program -- Colored Text

    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.
     
  15. Unread #8 - Aug 14, 2007 at 5:18 AM
  16. Zeh Progage
    Referrals:
    0

    Zeh Progage Guest

    Simple C++ Program -- Colored Text

    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
     
  17. Unread #9 - Aug 14, 2007 at 1:44 PM
  18. Zyloch
    Joined:
    Apr 21, 2005
    Posts:
    63
    Referrals:
    0
    Sythe Gold:
    0

    Zyloch Member

    Simple C++ Program -- Colored Text

    Yep, thanks :) I just wanted some clarification, because I'm just venturing into programming for different operating systems, and it's a zoo.
     
< I need something... | [C++] My First Script [BASIC] >

Users viewing this thread
1 guest


 
 
Adblock breaks this site