Thread: Linux Color (quazi NOOB)

  1. #1
    Registered User
    Join Date
    Nov 2002
    Posts
    4

    Question Linux Color (quazi NOOB)

    Probably the most asked question in windows converted to linux:
    How can you have collored text in a linux console program.


    And if anyone knows, in gVIM, how do you get it to keep you color scheme?

  2. #2
    Refugee face_master's Avatar
    Join Date
    Aug 2001
    Posts
    2,052
    This search would probably be more effective than just 'color'
    http://www.cprogramming.com/cboard/s...der=descending

  3. #3
    Registered User unixOZ's Avatar
    Join Date
    Feb 2002
    Posts
    91
    This is how I do it

    Code:
    char green[11]="\033[1;32m";
    char blue[11]="\033[1;34m";
    
    printf("%sThis is how you use colors\n", blue);
    printf("%s-------------------\n", green);
    I believe that there are various alternatives

  4. #4
    Registered User moi's Avatar
    Join Date
    Jul 2002
    Posts
    946
    Originally posted by unixOZ
    This is how I do it

    Code:
    char green[11]="\033[1;32m";
    char blue[11]="\033[1;34m";
    
    printf("%sThis is how you use colors\n", blue);
    printf("%s-------------------\n", green);
    I believe that there are various alternatives
    why [11] and not [8]?
    hello, internet!

  5. #5
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    >>why [11] and not [8]?
    Why not [] ?

    char green[]="\033[1;32m";
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  6. #6
    Registered User unixOZ's Avatar
    Join Date
    Feb 2002
    Posts
    91
    char green[]="\033[1;32m"; is better

  7. #7
    Comment your source code! Lynux-Penguin's Avatar
    Join Date
    Apr 2002
    Posts
    533
    here is a good explanation:
    http://www.linuxgazette.com/issue65/padala.html

    -Luke

    PS:
    next time try:
    http://www.google.com/linux
    Asking the right question is sometimes more important than knowing the answer.
    Please read the FAQ
    C Reference Card (A MUST!)
    Pointers and Memory
    The Essentials
    CString lib

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Thinking of upgrading to linux...
    By Yarin in forum General Discussions
    Replies: 37
    Last Post: 07-24-2009, 11:40 AM
  2. Wireless Network Linux & C Testbed
    By james457 in forum Networking/Device Communication
    Replies: 3
    Last Post: 06-11-2009, 11:03 AM
  3. Dabbling with Linux.
    By Hunter2 in forum Tech Board
    Replies: 21
    Last Post: 04-21-2005, 04:17 PM
  4. installing linux for the first time
    By Micko in forum Tech Board
    Replies: 9
    Last Post: 12-06-2004, 05:15 AM