Public Group

# ANSi Driver -inC++

This topic is 4524 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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.

##### Share on other sites
nobody help me ?I need an answer!

##### Share on other sites
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?

##### Share on other sites
Quote:
 Original post by programwizardYou should be using the line #include and not #include I can't see any other problems; why are you using getch() at the end?

And cstdio and cconio.

How does it "not work"?

##### Share on other sites
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.

##### Share on other sites
DukeAtreides076 this point I i write now ...but i don't know hwo to use ... Sertextatributte
:(( ...if u can help me ...

##### Share on other sites
Quote:
 Original post by TheFleaDukeAtreides076 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.

##### Share on other sites
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 :) )

1. 1
Rutin
28
2. 2
3. 3
4. 4
5. 5

• 11
• 11
• 10
• 13
• 20
• ### Forum Statistics

• Total Topics
632948
• Total Posts
3009398
• ### Who's Online (See full list)

There are no registered users currently online

×