Xcode C++ help! Changing text color

Discussion in 'Mac Programming' started by unknown.exe, Dec 1, 2007.

  1. unknown.exe macrumors member

    unknown.exe

    Joined:
    Sep 22, 2007
    Location:
    Somewhere on Earth
    #1
    Sup, I need a way to change the text color in my Xcode C++ prog... i'm pretty sure you can't do it but if there is a way can some one tell me?
    PS... Ive already tried setcolor and textcolor and they dont work even w/ conio.h...:apple:
     
  2. Krevnik macrumors 68040

    Krevnik

    Joined:
    Sep 8, 2003
    #2
    If you are using the command-line, you can print the ANSI color codes directly into your text stream.
     
  3. unknown.exe thread starter macrumors member

    unknown.exe

    Joined:
    Sep 22, 2007
    Location:
    Somewhere on Earth
    #3
    explain?
     
  4. unknown.exe thread starter macrumors member

    unknown.exe

    Joined:
    Sep 22, 2007
    Location:
    Somewhere on Earth
    #4
    its not from the command line, it's from xcode
     
  5. Krevnik macrumors 68040

    Krevnik

    Joined:
    Sep 8, 2003
    #5
    But you are trying to set text color via conio.h, which means your app is a command-line app, right?

    If you run the command-line app via XCode, it won't show any color, it will only show color when running the application via the Terminal.
     
  6. unknown.exe thread starter macrumors member

    unknown.exe

    Joined:
    Sep 22, 2007
    Location:
    Somewhere on Earth
    #6
    ok... but how do I use the codes? Example please?
     
  7. Krevnik macrumors 68040

    Krevnik

    Joined:
    Sep 8, 2003
    #7
    Lookup ANSI Color codes, pages like this one explain how they work.

    http://pueblo.sourceforge.net/doc/manual/ansi_color_codes.html

    You just need to add the characters into the text string that you write out to the console, and it will change the colors of the text written after it.

    However, again, this only works from the Terminal.
     

Share This Page