Coloured text

This is a discussion on Coloured text within the C++ Programming forums, part of the General Programming Boards category; I'd like to colour my text green, but dont know how, which is usually the reason i make a thread ...

  1. #1
    Let's do some coding! Welshy's Avatar
    Join Date
    Mar 2005
    Location
    Staffordshire University, UK
    Posts
    168

    Coloured text

    I'd like to colour my text green, but dont know how, which is usually the reason i make a thread here, hehe. I thought best to search the FAQ first and this code came up as an example:

    Code:
    #include <stdio.h> 
    #include <conio.h> 
    
    int main ( void )
    {
      textcolor ( MAGENTA );
      cprintf ( "This is a test\n" );
    
      return 0;
    }
    I tried using the code

    Code:
    textcolor ( MAGENTA );
    but it says it's undeclared. I tried it with the <stdoi.h> header file too but with no avail, could someone please help, thanks again

  2. #2
    Rabite SirCrono6's Avatar
    Join Date
    Nov 2003
    Location
    California, US
    Posts
    269
    What compiler, etc. are you using?

    - SirCrono6
    From C to shining C++!

    Great graphics, sounds, algorithms, AI, pathfinding, visual effects, cutscenes, etc., etc. do NOT make a good game.
    - Bubba

    IDE and Compiler - Code::Blocks with MinGW
    Operating System - Windows XP Professional x64 Edition

  3. #3
    Let's do some coding! Welshy's Avatar
    Join Date
    Mar 2005
    Location
    Staffordshire University, UK
    Posts
    168
    the most recent bloodshed, and win xp os

  4. #4
    Rabite SirCrono6's Avatar
    Join Date
    Nov 2003
    Location
    California, US
    Posts
    269
    I opened conio.h and it appears that there is no textcolor (or for that matter, anything about color) contained within it.

    - SirCrono6
    From C to shining C++!

    Great graphics, sounds, algorithms, AI, pathfinding, visual effects, cutscenes, etc., etc. do NOT make a good game.
    - Bubba

    IDE and Compiler - Code::Blocks with MinGW
    Operating System - Windows XP Professional x64 Edition

  5. #5
    Let's do some coding! Welshy's Avatar
    Join Date
    Mar 2005
    Location
    Staffordshire University, UK
    Posts
    168
    that just plan sucks, thanks anyway mate

  6. #6
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,630
    Excellent console programming tutorial for Windows:
    http://www.adrianxw.dk/SoftwareSite/...Consoles1.html

    gg

  7. #7
    Hardware Engineer
    Join Date
    Sep 2001
    Posts
    1,398

    Unhappy There is no color, graphics, soiund, or mouse in standard C++.

    Quote Originally Posted by Welshy
    that just plan sucks, thanks anyway mate
    FYI - There is no color, graphics, sound, or mouse in ANSI/ISO Standard C++. This means that not all compilers have these features, and each compiler will have different headers and functions for these things. That's why SirCrono6 asked you "Which Compiler?"

    There are functions that are standard in all Windows compilers, so the Windows-console functions from the link above should work with any compiler that can make Windows applications. And conio.h is psudo-standard... lots of compilers include it.

    Of course, it's OK to include non-standard (non-portable) code in your programs. But you should know when you're doing it, and sometimes you might want to keep the standard and non-standard stuff in separate modules (separate source files).

  8. #8
    C/C++ homeyg's Avatar
    Join Date
    Nov 2004
    Location
    Louisiana, USA
    Posts
    209
    Quote Originally Posted by Codeplug
    Excellent console programming tutorial for Windows:
    http://www.adrianxw.dk/SoftwareSite/...Consoles1.html

    gg
    Thanks for the link to that tutorial. It's a good one.

  9. #9
    Let's do some coding! Welshy's Avatar
    Join Date
    Mar 2005
    Location
    Staffordshire University, UK
    Posts
    168
    Quote Originally Posted by DougDbug
    FYI - There is no color, graphics, sound, or mouse in ANSI/ISO Standard C++. This means that not all compilers have these features, and each compiler will have different headers and functions for these things. That's why SirCrono6 asked you "Which Compiler?"

    There are functions that are standard in all Windows compilers, so the Windows-console functions from the link above should work with any compiler that can make Windows applications. And conio.h is psudo-standard... lots of compilers include it.

    Of course, it's OK to include non-standard (non-portable) code in your programs. But you should know when you're doing it, and sometimes you might want to keep the standard and non-standard stuff in separate modules (separate source files).
    Alright thanks, cleared it up for me, i thought there wasnt a way but i thought i may as well ask.

    Thanks for the link homeyg, i'll have a look into it

  10. #10
    C/C++ homeyg's Avatar
    Join Date
    Nov 2004
    Location
    Louisiana, USA
    Posts
    209
    It was codeplug that posted the link.

  11. #11
    Let's do some coding! Welshy's Avatar
    Join Date
    Mar 2005
    Location
    Staffordshire University, UK
    Posts
    168
    ah so it was, lol, i apologise, thanks codeplug :P sorry to bump the thread but you have to have manners....

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, 01:59 PM
  2. struct question
    By caduardo21 in forum Windows Programming
    Replies: 5
    Last Post: 01-31-2005, 03: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, 06:35 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21