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
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
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
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; }
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
Then you posted in the wrong forum. Try the C forum.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.
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
Hi Sang-drax
Ok, thank anyway for your help.
Thank
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,®s,®s);
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,®s,®s);
y++;
regs.h.ah=0x02;
regs.h.bh=0x00;
regs.h.dh=x;
regs.h.dl=y;
int86(VIDEO,®s,®s);
}
[\code]
more than you need , but will still help
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