GithubHelp home page GithubHelp logo

rarm / colors-for-c-c-console-application Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 0.0 3 KB

Limited, but fast and easy to use library to change colors in C console applications.

License: MIT License

C 100.00%

colors-for-c-c-console-application's Introduction

Colors for C/C++

This is a easy and quick to use library for console applications in C/C++.

It is limited, but has been tested in Linux and Windows (making it semi-cross-platform). It only supports the colors:

  1. White
  2. Red
  3. Green
  4. Blue
  5. Yellow

In Windows, it is supposed to work only if the background color of the console is black. If the background color is different, it may turn the background of the text black. However, it has not been tested with a different background color.

Nevertheless, it is a fast and simple to use library.

How to Use

The header file and the source code is in the src folder.

Include the Header

Include the header in your source code.

#include "colors.h"

Function

void scrclr(int COLOR)
Quick explanation

Use the scrclr function to change the color of the text that comes after it. For example, call the function scrclr to change the color to red; then, al the instances of printf will output the text in red.

Argument

The functions has one argument: COLOR. It receives one of the following symbolic constants:

Symbolic Constant Text Color
CLEAR White
RED Red
GREEN Green
BLUE Blue
YELLOW Yellow
Example
#include <stdio.h>
#include "color.h"

int main (void) {
    scrclr(WHITE);
    printf("This text is white.\n");

    scrclr(RED);
    printf("This text is red.\n");

    scrclr(GREEN);
    printf("This text is green.\n");

    scrclr(BLUE);
    printf("This text is blue.\n");

    scrclr(YELLOW);
    printf("This text is yellow.\n");

    scrclr(WHITE);
    printf("This text is white again.\n");

    return 0;
}

colors-for-c-c-console-application's People

Contributors

rarm avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.