changing text color in c

I'm writing my own Unix ls command in c and I was wondering if anyone knows how to or can point me to a tutorial that shows me how to change the text color of the filename depending on if it's a directory, regular file, linked file, etc..., like the real ls command does? Thanks.

You can use the \e with the different values for making the colors.

 printf("\e[35m["); //This will show a maroon/pink like color

Like wise you can use different numbers for showing appropriate colors.

Yeah, basically you print the escape character (either \e or \033, I prefer the latter because I'm used to it and \e isn't actually standard C - although as far as I know it is widely supported), an opening square bracket ('['), numbers separated by semicolons and the letter 'm' (other letters are used for other types of escape codes).
To get back to the default, you must use '0' as the number. If several numbers are specified they will be executed in the order they appear, thus if two incompatible options are set (like green and red at the same time), the last one will be effective. You can prefix all your options with a '0' like "\033[0;<your options here>m", in case some of them are already set.
Don't forget to print a "\033[0m" at the end if you don't want the rest of your output to be messed.

printf("\033[0;31mhello, world\033[0m\n"); // prints "hello, world" in red

For a reference on ANSI escape codes, see here

Using curses will keep terminal specific escape sequences out of your program.

Are there any non-ANSI terminals left in this world?