Thread: more complex C++

  1. #1
    'AlHamdulillah
    Join Date
    Feb 2003
    Posts
    790

    more complex C++

    I have completed the basic learning of classes and structs, and have done some OOP. Where can I get a reference of the different system commands? as well as color commands for console output.

  2. #2
    samurai warrior nextus's Avatar
    Join Date
    Nov 2001
    Posts
    196
    i think http://gametutorials.com/ have some very good example..go under the c++ section
    nextus, the samurai warrior

  3. #3
    Registered User abrege's Avatar
    Join Date
    Nov 2002
    Posts
    369

    Re: more complex C++

    Originally posted by EvBladeRunnervE
    as well as color commands for console output.
    This should work nicely
    Code:
    #include <iostream>
    #include <windows.h>
    using namespace std;
    
    #define RED FOREGROUND_INTENSITY | FOREGROUND_RED
    #define GREEN FOREGROUND_INTENSITY | FOREGROUND_GREEN
    #define BLUE FOREGROUND_INTENSITY | FOREGROUND_BLUE
    #define YELLOW FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN
    #define PURPLE FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_BLUE
    
    void colorText(char *text, char clr)
    {
    	HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
    	SetConsoleTextAttribute(hOut, clr);
    
    	cout << text;
    	SetConsoleTextAttribute(hOut, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
    }
    
    int main()
    {
    	colorText("Red\n", RED);
    	colorText("Green\n", GREEN);
    	colorText("Blue\n", BLUE);
    	colorText("Yellow\n", RED | GREEN);
    	colorText("Purple\n", RED | BLUE);
    
    	return 0;
    }
    I am against the teaching of evolution in schools. I am also against widespread
    literacy and the refrigeration of food.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Complex Number Implementation
    By CaptainMorgan in forum C Programming
    Replies: 2
    Last Post: 02-25-2006, 09:47 PM
  2. Why am I getting 'undelcared identifier' ???
    By Bill83 in forum C++ Programming
    Replies: 2
    Last Post: 02-15-2006, 01:00 PM
  3. arithmetic operator friend functions
    By linucksrox in forum C++ Programming
    Replies: 7
    Last Post: 02-06-2006, 11:39 PM
  4. 2 am complex double conversion woes
    By Roule in forum C++ Programming
    Replies: 1
    Last Post: 10-14-2004, 02:53 PM
  5. Problem from texbook
    By Unregistered in forum C++ Programming
    Replies: 5
    Last Post: 07-26-2002, 04:55 AM