Within the C programming language, you should use the printf() perform to print textual content and variables to the console. The printf() perform takes a format string as its first argument, which specifies how the output must be formatted. The format string can include 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 can even use the printf() perform to print variables in colour. To do that, you should use the %c escape sequence, adopted by a colour code. The next desk lists the colour codes that you should use:
Coloration | Code |
---|---|
Black | 33[0m |
Crimson | 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(“