Color Text error

DaveCas (9)
Hello,
I have this code which compiles correctly but for some reason when I run the program the output is:

sh: 1: color: not found
Hello


And "Hello" is in regular text color.
I have tried googling this but nothing relevant comes up. I'm thinking that I may have to install something but I'm not too sure about that.


Here is the code:

1
2
3
4
5
6
7
8
9
10
11
#include <stdlib.h>
#include <iostream>
using namespace std;

int main() 
{
system( "color 1A" );
cout <<"Hello\n";

return(0); 
}


I am using Linux Mint 14 (based on Ubuntu 12.04) with g++ compiler.

Thanks.
jlb (170)
Probably because color is Windows specific.

usandfriends (186)
dont use system("...");
http://www.cplusplus.com/forum/articles/11153/

use this, I use it and it works well:
http://www.cplusplus.com/articles/2ywTURfi/
Last edited on
DaveCas (9)
Well that's good to know... I would think Linux would have color too.

Thanks.
DaveCas (9)
The bottom link is for windows, will it work for linux?
usandfriends (186)
I have no idea, you can try it.
DaveCas (9)
tried it... doesn't work. windows.h is not for linux and neither is concol.h which is in the second code.
Last edited on
DaveCas (9)
ok I found how to do it
http://stackoverflow.com/questions/2616906/how-do-i-output-coloured-text-to-a-linux-terminal
when I googled it, everything was for windows but here is one for linux and it works.

Thanks for the help.
Registered users can post here. Sign in or register to post.