Files should get white font,directory should be in blue font and executable file should be in green font.
            Asked
            
        
        
            Active
            
        
            Viewed 809 times
        
    -4
            
            
        - 
                    1possible duplicate of [color text in terminal aplications in unix](http://stackoverflow.com/questions/3585846/color-text-in-terminal-aplications-in-unix) – mch Jul 02 '15 at 09:58
2 Answers
1
            
            
        You can use ANSI sequences which are supported by most consoles.
printf("\x1b[34m" "Blue text");
printf("\x1b[32m" "Green text");
and use "\x1b[0m" to set it back to the default colour.
 
    
    
        Bathsheba
        
- 231,907
- 34
- 361
- 483
1
            
            
        Try this:
    #include <stdio.h>
#define KRED  "\x1B[31m"
#define KGRN  "\x1B[32m"
#define KYEL  "\x1B[33m"
#define KMAG  "\x1B[35m"
#define KCYN  "\x1B[36m"
#define RESET "\033[0m"
int main(void){
    printf(KRED "This is KRED\n"RESET);
    printf(KGRN "This is KGRN\n"RESET);
    printf(KYEL "This is KYEL\n"RESET);
    printf(KMAG "This is KMAG\n"RESET);
    printf(KCYN "This is KCYN\n"RESET);
    return 0;
}
After you setup your favorite color do not forget to allways set it back to its default one.
 
    
    
        Michi
        
- 5,175
- 7
- 33
- 58
 
    