color

This is a discussion on color within the C++ Programming forums, part of the General Programming Boards category; hi there, i have a school project now, i would like to put some color on the text but don't ...

  1. #1
    Registered User
    Join Date
    Mar 2003
    Posts
    11

    Question color

    hi there,

    i have a school project now, i would like to put some color on the text but don't know where to look for it like which .h file to use and how to use?

    thank

  2. #2
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    search the bords.its been covered many times.
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

  3. #3
    RoD
    RoD is offline
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331
    oldies but goodies!

    Code:
    /*	Steven Billington
    *	October 30, 2002
    *	ColorTest.cpp
    *
    *   petter-color.h allows you to use colors with cout in win32
    *   Copyright (c) 2002
    *
    *   petter-color.h made by Petter ("Sang-drax") Strandmark
    */
    
    /*	Preprocessor Directives*/
    #include <iostream.h>
    #include <windows.h>
    #include <petter-color.h>
    #include <stdlib.h>
    
    /*	Namespaces needed for correct functioning*/
    using namespace std;
    using namespace Petter;
    
    
    int main()
    {
    	/*	Examples of colored text*/
    	std::cout<<RED<<"This text is red.\n";
    	std::cout<<BLUE<<"This text is blue.\n";
    
    	system("pause");
    	/*	Good practice to return value for main*/
    	return 0;
    
    }

  4. #4
    Registered User
    Join Date
    Mar 2003
    Posts
    11

    color

    Hi there

    Thank for replying to my help so fast, there is 1 problem and that is in my school, we only make use of stdio.h so we don't really know the iostream.h format type of program.
    Can you kindly send me a stdio.h format of the program

    Hundred Thank

  5. #5
    S Sang-drax's Avatar
    Join Date
    May 2002
    Location
    Göteborg, Sweden
    Posts
    2,072

    Re: color

    Originally posted by leinad079
    Thank for replying to my help so fast, there is 1 problem and that is in my school, we only make use of stdio.h so we don't really know the iostream.h format type of program.
    Then you posted in the wrong forum. Try the C forum.
    You could probably modify my header to work with stdio.h, though.
    Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling

  6. #6
    Registered User
    Join Date
    Mar 2003
    Posts
    11

    Re: Reply to color

    Hi Sang-drax

    Ok, thank anyway for your help.

    Thank

  7. #7
    Registered User SAMSAM's Avatar
    Join Date
    Nov 2001
    Posts
    218
    here you go:

    [code]

    #include <stdio.h>
    #include <dos.h>

    #define VIDEO 0x10
    #define BLUE 0x1F

    void dcolor(char ch,unsigned char color);

    void main()
    {
    char *text = "my name is leinad?";
    unsigned char x;

    while(*text)
    {
    dcolor(*text,BLUE);
    text++;
    }

    putchar('\n');
    }

    void dcolor(char ch,unsigned char color)
    {
    union REGS regs;
    int x,y;

    // cursor

    regs.h.ah = 0x03;
    regs.h.bh = 0x00;
    int86(VIDEO,&regs,&regs);
    y = regs.h.dl; //save Y pos.
    x = regs.h.dh; //save X pos.

    /* write the color char */

    regs.h.ah = 0x09; //Write color
    regs.h.al = ch; //character
    regs.h.bh = 0x00;
    regs.h.bl = color; //color
    regs.x.cx = 1;
    int86(VIDEO,&regs,&regs);



    y++;



    regs.h.ah=0x02;
    regs.h.bh=0x00;
    regs.h.dh=x;
    regs.h.dl=y;
    int86(VIDEO,&regs,&regs);
    }



    [\code]

    more than you need , but will still help

  8. #8
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    SAMSAM's code will only work on a DOS compiler, so if you're using Dev-C++ or Microsoft Visual C++ it will not work. Not sure about Borland though.
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Critique my lighting model.
    By psychopath in forum Game Programming
    Replies: 4
    Last Post: 08-12-2006, 06:23 PM
  2. egavga.bgi problem
    By sunil21 in forum A Brief History of Cprogramming.com
    Replies: 3
    Last Post: 09-22-2003, 05:06 PM
  3. My opinion on skin color
    By Leeman_s in forum A Brief History of Cprogramming.com
    Replies: 8
    Last Post: 07-11-2003, 12:12 PM
  4. [WinAPI] Developing a color customizable program
    By Templario in forum Windows Programming
    Replies: 6
    Last Post: 02-04-2003, 05:12 PM
  5. Just one Question?
    By Irish-Slasher in forum C++ Programming
    Replies: 6
    Last Post: 02-12-2002, 09:19 AM

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