On Sun, 15 Jun 2008 19:38:01 -0700, Gestorm wrote:
It seems that the standard c library doesn't give any support on this.
I googled this question and found that the code would not be portable.
Then how can I do this under linux ? Thanks! ^_^
It is not a Linux specific thing it is a terminal type specific thing.
On my terminal I can use:
fputs( "\033[31mHello World!\n", stdout );
Lookup the different codes on:
http://www.ibm.com/developerworks/li.../l-tip-prompt/
in particular, lookup the code for how to reset it back to what might be
the "correct" colour. My PS1 (prompt) variable does this for me so I
haven't included it above.
If you want to play with this sort of thing, remember that when you screw
up your terminal, you can usually type reset[enter] to get it back, and
this usually works even if you can't see the letters coming up.