Is it possible to change Linux Terminal text and background color using C?

Viewed 725

I want to change the colour of background UBUNTU TERMINAL with the help of c language .is this possible ?

1 Answers

You can use escape sequences

printf("\033[37m\033[41m"); // White foreground / Red background
printf("Something\n");
printf("\033[0m");          // Reset

This is the table of colors:

Foreground:

30 Black
31 Red
32 Green
33 Yellow
34 Blue
35 Magenta
36 Cyan
37 White

Background:

40 Black
41 Red
42 Green
43 Yellow
44 Blue
45 Magenta
46 Cyan
47 White

0 Reset all
1 Bold
Related