Within the C programming language, you should use the printf() operate to print textual content and variables to the console. The printf() operate takes a format string as its first argument, which specifies how the output needs to be formatted. The format string can comprise placeholders for variables, that are represented by % characters adopted by a sort specifier. For instance, the next code prints the worth of the variable ‘x’ as an integer:
printf(“The worth of x is %dn”, x);
You may as well use the printf() operate to print variables in coloration. To do that, you’ll want to use the %c escape sequence, adopted by a coloration code. The next desk lists the colour codes that you should use:
Coloration | Code |
---|---|
Black | 33[0m |
Purple | 33[31m |
Inexperienced | 33[32m |
Yellow | 33[33m |
Blue | 33[34m |
Magenta | 33[35m |
Cyan | 33[36m |
White | 33[37m |
For instance, the next code prints the worth of the variable ‘x’ in pink:
printf(“