how do i change the color in c++?
how do i change the color in c++?
Search the boards, this has been discussed many many times.
Lol, I find it sad how little people can be bothered to search for a topic, before they post about it.
if (topic already discussed) {read it's thread/s/;}
else{post new thread;}
> Lol, I find it sad how little people can be bothered to search for a topic, before they post about it.
> Search the boards, this has been discussed many many times.
Apparently by the same person:
http://www.cprogramming.com/cboard/s...threadid=17889
The world is waiting. I must leave you now.
include conio.h
syntax: textcolor(RED); // makes the text colour red
read the conio.h file for more colours which you can use
Enjoy
tudehopet uses Borland Compiler 5.5
and Visual C++ 6.
I did exactly that -
> textcolor(RED); // makes the text colour red
Just like that, without quotes:
With quotes textcolor("RED");tmp.c: In function `main':
tmp.c:6: `RED' undeclared (first use in this function)
tmp.c:6: (Each undeclared identifier is reported only once
tmp.c:6: for each function it appears in.)
Thanks for the portable code, I really enjoyed it.c:\windows\TEMP\ccT8FYfb.o(.text+0x1c):tmp.c: undefined reference to `textcolor'
The world is waiting. I must leave you now.
you also have to include conio.c
Sorry for that.
I think it is compiler specific.
I use borland compiler 5.5
As for the "RED" in inverted comma's, that is actually a value in an enum. ie enum COLORS {RED;};
this makes RED = 0;
but don't type that in.
I think if you edit the conio.h file, look for the enum COLORS, I assume by the errors you are using Dev-C++, if there is enum COLORS the you should see a list of colours which you can choose from.
I hope that this works
tudehopet uses Borland Compiler 5.5
and Visual C++ 6.
> you also have to include conio.c
I've never had to do this.
I don't even have a conio.c.
> , I assume by the errors you are using Dev-C++,
I use gcc.
The world is waiting. I must leave you now.
Well gcc is actually the what Dev-C++ uses to compile its source code. So it should use the same include files.
Just have a look at the conio.h file for the enum COLORS.
tudehopet uses Borland Compiler 5.5
and Visual C++ 6.
This has been asked and answered countless times. Here's the Windows version that I use for this question:
-PreludeCode:#include <iostream> #include <windows.h> using namespace std; int main ( void ) { HANDLE h; h = GetStdHandle ( STD_OUTPUT_HANDLE ); SetConsoleTextAttribute ( h, FOREGROUND_RED | FOREGROUND_GREEN ); cout<<"The "; SetConsoleTextAttribute ( h, FOREGROUND_RED ); cout<<"search "; SetConsoleTextAttribute ( h, FOREGROUND_GREEN ); cout<<"feature "; SetConsoleTextAttribute ( h, FOREGROUND_INTENSITY | FOREGROUND_BLUE ); cout<<"is "; SetConsoleTextAttribute ( h, FOREGROUND_INTENSITY | FOREGROUND_RED ); cout<<"very "; SetConsoleTextAttribute ( h, FOREGROUND_INTENSITY | FOREGROUND_GREEN ); cout<<"useful. "; SetConsoleTextAttribute ( h, FOREGROUND_INTENSITY | FOREGROUND_BLUE | FOREGROUND_RED ); cout<<"Use "; SetConsoleTextAttribute ( h, FOREGROUND_BLUE | FOREGROUND_GREEN ); cout<<"it!"<<endl; SetConsoleTextAttribute(h, FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED); return EXIT_SUCCESS; }
My best code is written with the delete key.