Source code - color.zip

Find C and C++ source code to help you learn to program. You can submit your own code, or you can simply browse and download the code of others.

Finally, you might want to check out Code Cogs - An Open Source Scientific Library / Database in C++ for more code.

Index :: Utilities / color.zip
color.zip
resource information
Title color.zip
URL http://www.cprogramming.com/source/color.zip
Category 8
Description shows a way to change the color of the text in a text window.
Contact Michael Marques
Added 06-24-2003 at 07:22 p.m.
Last Updated 06-24-2003 at 08:23 p.m.
rating
Current Rating 5
Rate Resource
 
reviews
Number of Reviews 5
Review this Resource
Reviews:
  • just add the line "system ("PAUSE");" right before the return of main. #include "global.h" //header files, function prototypes, & classes void setcolor(unsigned short color) { //begining of set color funtion HANDLE hCon = GetStdHandle(STD_OUTPUT_HANDLE); //gets std handle SetConsoleTextAttribute(hCon,color); //Sets Console Text Attribute HCon color. } //end of set color funtion int main() { //begining of main funtion printf("What color do you want the text to be?(1 = blue, 2 = green, 4 = red, 14 = yellow)"); //displays text scanf("%d", &C.I); //scans number setcolor(C.I); //sets color cout << " _____ ____ ____ _____\n"; //displays text cout << "|_ _|| __ || ___||_ _|\n"; //displays text cout << " | | | __||__ | |\n"; //displays text cout << " | | | |__ __| | | |\n"; //displays text cout << " |_| |____||____| |_|\n"; //displays text system ("PAUSE"); return 0; //returns 0 } //end of main function
    posted at 09:11 p.m. on 12-20-2004
  • lol people. Here's the thing, when programs are done running their tasks, they terminate, everything goes so fast you don't see anything, you just have to give it an infinate loop at the end before return. for(;;), while(1);, while(true); Either of those
    posted at 07:53 p.m. on 08-26-2004
  • I had to work a little to get the source to compile with Dev-C++ 4.9.8.7, but finally got it to work with warnings...i added the line "#include <iostream>" for cout, then before the functions "using namespace std;" for cout, and also to fix the problem of the program ending early, add the line "getchar();" TWO times before the return statement. sloppy code...
    posted at 08:13 p.m. on 04-05-2004
  • yeah... I dont understand it,,, "choose color 1=blue" you press 1, and the progg ends...wierd..
    posted at 11:13 a.m. on 03-13-2004
  • seems tow ork fine. when you run the .exe it ends before you have a real chance of seeing the colour but it is there.....
    posted at 07:42 p.m. on 11-30-2003