ANSi Driver -inC++

Started by
6 comments, last by TheFlea 17 years, 10 months ago
Hi, I use windows Xp and I want to use the driver ANsi;In "c:\windows\system32\config.nt" and there , in config.nt I wrote device=c:\windows\system32\ansi.sys . I restart my computer and I try to use Ansi colors; This is the code
#include <iostream.h>
#include <stdio.h>
#include <conio.h>
void main ()
{int a,b;
printf("\033[31m");
cout<<"a=";cin>>a;
cout<<"b=";cin>>b;
cout<<"Suma este..."<<a+b<<endl;
getch();} // he want to return a color Red but he doesn't work... I need help... see u.
Advertisement
nobody help me ?I need an answer!
You should be using the line #include <iostream> and not #include <iostream.h>
I can't see any other problems; why are you using getch() at the end?
------------------------------Support the Blue Skies in Games Campaign!A blog... of sorts.As a general rule, if you don't have a general rule in your signature, you aren't as awesome as someone who does. General rules roxor teh big one one ones.
Quote:Original post by programwizard
You should be using the line #include <iostream> and not #include <iostream.h>
I can't see any other problems; why are you using getch() at the end?


And cstdio and cconio.

How does it "not work"?
IIRC, windows NT and later will ONLY use the ANSI driver for 16-bit applications. Just use the win32 SetConsoleTextAttribute fuction if you want color in a 32-bit console app.
DukeAtreides076 this point I i write now ...but i don't know hwo to use ... Sertextatributte
:(( ...if u can help me ...
Quote:Original post by TheFlea
DukeAtreides076 this point I i write now ...but i don't know hwo to use ... Sertextatributte
:(( ...if u can help me ...

If you want to change color, use SCTA like this:

enum COLOR_ENUM{	BLACK, 	BLUE, 	GREEN, 	AQUA, 	RED, 	PURPLE, 	YELLOW, 	WHITE, 	GRAY, 	LIGHT_BLUE, 	LIGHT_GREEN, 	LIGHT_AQUA, 	LIGHT_RED, 	LIGHT_PURPLE, 	LIGHT_YELLOW, 	BRIGHT_WHITE};...//Before you write text, call SCTA like this:SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), LIGHT_GREEN);

This is easier to use if you use a stream manipulator.

P.S.
Don't forget to restore the original text color.
Thank you a lot, this is the great place, because in other forum if I do this question I don't give any help (sorry for my english :) )

This topic is closed to new replies.

Advertisement