Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,971 questions

51,913 answers

573 users

How to write colored text in printf with C

1 Answer

0 votes
#include <stdio.h>

#define RESET   "\033[0m"
#define BLACK   "\033[30m"      
#define RED     "\033[31m"      
#define GREEN   "\033[32m"      
#define YELLOW  "\033[33m"      
#define BLUE    "\033[34m"      
#define MAGENTA "\033[35m"      
#define CYAN    "\033[36m"      
#define WHITE   "\033[37m"      

int main ()
{
    printf(GREEN "%s\n", "green text" RESET);
    printf(RED "%s\n", "red text" RESET);
    printf(YELLOW "%s\n", "yellow text" RESET);

    return 0;
}

  
/*
run:
  
green text
red text
yellow text
  
*/

 



answered Jul 18, 2024 by avibootz

Related questions

1 answer 71 views
1 answer 302 views
1 answer 71 views
1 answer 214 views
2 answers 162 views
162 views asked Apr 10, 2021 by avibootz
1 answer 160 views
...