Thread: Coloring My Text

  1. #1
    Registered User
    Join Date
    Jan 2008
    Posts
    11

    Coloring My Text

    Hey, everyone. Right now, I'm trying to change the color of both my text and my background. I searched in the FAQ section, but it wasn't clear enough for me to understand it. I'm currently running in Code::Blocks, with the GNU compiler. Would it help if I switched my compiler to either Visual C++, Borland, Digital Mars, Open WatCom, or SDCC (These are the compilers I have available). Thanks.

    EDIT: here is the warning I am getting, " 'textcolor' undeclared (first use of function)"
    Last edited by bjl; 02-05-2008 at 06:55 PM.

  2. #2
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Ireland
    Posts
    8,446
    The compiler wouldn't make a difference. It's a library you need. PDCurses is a portable one based on ncurses. http://pdcurses.sourceforge.net/
    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  3. #3
    Registered User
    Join Date
    Jan 2008
    Posts
    11
    So in order to do this, I need to save it as a header file and include it in the preprocessor, correct? If you could give a step-by-step that would be great. Sorry, I've never used any library other than the standard one as far as I'm aware.

  4. #4
    coder
    Join Date
    Feb 2008
    Posts
    127
    The correct syntax should be textColor instead of textcolor
    Perhaps that's why u get "undeclared function" warning
    check it out

  5. #5
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Ireland
    Posts
    8,446
    I would be tempted to advise you learn a little bit more about C++, getting familiar with the language and some of its operations, before attempting things like coloring text

    But if you are in an hurry and never used a library before, then I'd suggest you start by downloading the library above and read through the documentation. You'll want to read carefully the file named INSTALL in the root folder.

    If problems arise, ask away then.
    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  6. #6
    Registered User
    Join Date
    Jan 2008
    Posts
    11
    Quote Originally Posted by carlorfeo View Post
    The correct syntax should be textColor instead of textcolor
    Perhaps that's why u get "undeclared function" warning
    check it out
    Nope, unfortunately not. Here is the top part of the code:

    Code:
    #include <windows.h>
    #include <iostream>
    #include <stdlib.h>
    #include <time.h>
    #include <conio.h>
    using namespace std;
    
    //Some code here . . .
    
    int main()
    {
        textColor (13);
    
        //We are designing the main menu
        cout << "Welcome to the Main Menu.  To continue, please press enter.";
        cin.get();
        cout << "\n\nSo you think you are ready to enter the fight.  So be it.";
        cin.get();
        clrscr();
    And I still get the warning

  7. #7
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Ireland
    Posts
    8,446
    Avoid conio.h and windows.h

    Just use something more portable like PDCurses.
    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  8. #8
    Registered User
    Join Date
    Jan 2008
    Posts
    11
    You know, seeing as I'm not understanding all of what you're saying, I'll probably forgo coloring my text until I learn more about the language as you said . Thanks though.

  9. #9
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Ireland
    Posts
    8,446
    A convert! Welcome
    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  10. #10
    coder
    Join Date
    Feb 2008
    Posts
    127
    did you #include the code::blocks header?

    you need the right header for every library you want to use

    anyway I agree with Mario F.
    code:blocks doesn't seem to be the right library for beginner.
    I don't know PDCurses, so I'd suggest SDL, which is very easy, portable, and documented.

  11. #11
    coder
    Join Date
    Feb 2008
    Posts
    127
    http://aaroncox.net/tutorials/2dtutorials/index.html

    here is a nice, clear tutorial, if you want get started using an external library

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. A bunch of Linker Errors...
    By Junior89 in forum Windows Programming
    Replies: 4
    Last Post: 01-06-2006, 02:59 PM
  2. struct question
    By caduardo21 in forum Windows Programming
    Replies: 5
    Last Post: 01-31-2005, 04:49 PM
  3. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 09:54 AM
  4. Ok, Structs, I need help I am not familiar with them
    By incognito in forum C++ Programming
    Replies: 7
    Last Post: 06-29-2002, 09:45 PM
  5. Outputting String arrays in windows
    By Xterria in forum Game Programming
    Replies: 11
    Last Post: 11-13-2001, 07:35 PM