How do you do colored text in MSVC 6.0? Could anyone give me a little snippet of code that outputs say like "Hello" in a color? Thanks!
How do you do colored text in MSVC 6.0? Could anyone give me a little snippet of code that outputs say like "Hello" in a color? Thanks!
are you talking about the color in the compiler or the color when you open the msdos window???
Considering he wants code that will output "Hello" in a color, I'd say he wants it to have colored text in the dos window
Programmer's Law:
If your program doesn't work, look for the part that you didn't think was
important.
I would like it to say, output "Hello" in let's just say green text in the MSDOS console. Could someone please show me an example? I need it for my battleship game. ::Wink::Wink::.
You need to read the FAQ before posting these type of questions.
When all else fails, read the instructions.
If you're posting code, use code tags: [code] /* insert code here */ [/code]
Awww...man sorry. I'm new to this forum as of today.
No harm done
Welcome to cprog.com, enjoy your stay!
When all else fails, read the instructions.
If you're posting code, use code tags: [code] /* insert code here */ [/code]
Here I made a Color File if you need it
You must #include "colors.h" and colors.cpp
Functions:
Before everything you must do InitColor();
then theres
SetPosXY(x,y) <same thing as gotoxy;
and then SetColor(FOREGROUND|BACKGROUND)
SetPosXYAndColor(x,y,TEXT, COLOR)
using that code, to write hello in color lets say green background red
Code:#include <iostream.h> #include "colors.h" void main() { InitColor(); SetColor(GREEN|BRED); cout<<"hello"<<endl; }
>>void main()
Nice
When all else fails, read the instructions.
If you're posting code, use code tags: [code] /* insert code here */ [/code]
I've alo created a color header for your convenience.
It works together with cout:
Code:#include <Petter-Color.h> #include <iostream> int main() { using namespace std; using namespace Petter; cout << RED << "This is red.\n"; cout << BLUE << "This is blue"; }
Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling
No return value in main()
Nice
When I leave out return 0, I usually get this warning:
You should always explicitly state return 0, unless, you know, you're a lazy programmer.Code:warning C4508: 'main' : function should return a value; 'void' return type assumed
The "should" in that sentence was just me imposing my style on everyone. Why can't you just accept that my style is simply awesome.Originally posted by vVv
What your compiler has to say about it is totally meaningless. The Standard permits omitting it, that's what matters.
It's not that meaningless. The compiler is letting you know that you're using an acceptable but lazy programming style.
> You should always explicitly state return 0, unless, you know, you're a lazy programmer.
The "should'' here is also meaningless, since it's completely a matter of style and nothing is mandating you to do it.
Besides, you'll make the compiler shut up if you just put return 0.
Do you leave out return 0 in your code, vVv, or were you just pointing out that "The Standard" allows it?
Of course, I could just look at your code to answer that question, but I want you to work, kid!!!
>(I suppose you're using some old DOS Borland crap compiler - get a better one).
I'm using Microsoft Visual C++ 6.0.
>Judging by your posts, I think you are 13 as well
No, I'm an adult. Adults can have fun, too. No one told me those smiley faces and humor were reserved for kids only. Look at Hammer: he occasionally uses those smiley faces - and he's 40!
LOL I hope he's not reading this.