Skip to content

🍭 A single-header C library for printing colored text to the console

License

Notifications You must be signed in to change notification settings

JosefVesely/printfcolor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

printfcolor Library

A single-header C library for printing colored text to the console. It supports both Windows and Unix-like systems.

How to use

Include the printfcolor.h header file in your C project:

#include "printfcolor.h"

Example code

#include "printfcolor.h"

int main()
{
    printfc_fg(BLUE, "Blue text\n");
    printfc_fg(MAGENTA, "Magenta text\n\n");

    printfc_bg(GREEN, "Green background\n");
    printfc_bg(RED, "Red background\n\n");

    printfc(WHITE, BLUE, "White on blue\n");
    printfc(MAGENTA, CYAN, "Magenta on cyan\n");
}

Output:

Example output

Compatibility

  • Windows: Uses Windows Console API.
  • Unix-like Systems: Uses ANSI escape codes.

Error Handling

  • Invalid Color Code: Prints an error message and returns -1.
  • Console Info Retrieval Failure: Prints an error message and returns -1.

License

This project is licensed under the MIT License - see the LICENSE file for details

About

🍭 A single-header C library for printing colored text to the console

Topics

Resources

License

Stars

Watchers

Forks

Languages