DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   C++ (http://www.daniweb.com/forums/forum8.html)
-   -   Change text color using visual c++ (http://www.daniweb.com/forums/thread9921.html)

phr34k1sh Mar 14th, 2009 1:22 am
Simple way...
 
Alright... this is all i do... inside of main... right before i access cout... i simply just put on a line before this...

system("color 0a");

This is processing a batch command... and batch is quite simple... if you would like a definition of how this works, simply go to "cmd.exe" and type "help color" this will explain how to use this... you can change the background color of the console with this method... here is an example...

#include "header.h"

using namespace std;

int main ()
{
        system("title Hello World.");
        system("color 0a");
        cout<<"Hello world.";
        system("pause >nul");
        return 0;
}

header.h contains
#include <iostream>

so if you're using an older c++ compiler... replace
#include "header.h"
with
#include <iostream>

otherwise you know what to do... peace... hope i could help.


All times are GMT -4. The time now is 7:09 pm.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC