Source code -

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 /
resource information
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.
Current Rating 4.82608695652174
Rate Resource
Number of Reviews 9
Review this Resource
  • wh0cd332599 <a href=>cheap cialis pills online</a> <a href=>amitriptyline without prescription</a>
    posted at 10:28 p.m. on 06-13-2017
  • PglqsM <a href="">oplqxxsdcyqb</a>, [url=]iiftzlgbegfp[/url], [link=]ultxzmxwvgba[/link],
    posted at 03:53 a.m. on 12-20-2016
  • OHQt12 <a href="">akvebesdbhed</a>, [url=]qlcamppzfhzo[/url], [link=]wfcttnwyzwrb[/link],
    posted at 10:20 a.m. on 07-14-2016
  • gLLD1Y <a href="">mlbmatustcgl</a>, [url=]rrcyfuawhdwg[/url], [link=]jhnklbsflzzj[/link],
    posted at 11:19 p.m. on 07-02-2016
  • 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++, 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