The Linux Terminal program uses C language to change the color of the output word

Source: Internet
Author: User
Tags clear screen

Color code:

Format: echo "\033[word background color; font Color m string \033[0m" for example: echo "\033[41;36m something here \033[0m" where 41 of the position represents the background, 36 of the position is the color that represents the word, those ASCII code Is the whole story of the color call. \033[, M. ... \033[0m Word background color range:----4940: Black 41: Crimson 42: Green 43: Yellow 44: Blue 45: Purple 46: Dark green 47: White word color: 3930: Black 31: Red 32: Green 33: Yellow 34: Blue 35: Purple 36: Dark green 37: Description of the white ===============================================ansi control code \33[0m Close all properties \33[1m set high brightness \33[4m underline \33[ 5m flashing \33[7m \33[8m blanking \33[30m--\33[37m setting foreground color \33[40m--\33[47m setting background color \33[na cursor up n rows \33[nb cursor down n lines \33[nc cursor right shift n rows \33[ ND cursor left n line \33[y;xh set cursor position \33[2j Clear Screen \33[k clear the contents from cursor to end of line \33[s save cursor position \33[u restore cursor position \33[?25l Hide cursor \33[?25h display cursor

  

Instance:

#include <stdio.h>int main (int Argc,char **argv) {    printf ("\033[31m the ... \n\033[0m");    printf ("\033[2;7;1mheoo.\n\033[2;7;0m");    printf ("\033[41;36msomthe here\n\033[0m");    return 0;}

  

The Linux Terminal program uses C language to change the color of the output word

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.