
- C Programming Tutorial
- C - Home
- C - Overview
- C - Environment Setup
- C - Program Structure
- C - Basic Syntax
- C - Data Types
- C - Variables
- C - Constants
- C - Storage Classes
- C - Operators
- C - Decision Making
- C - Loops
- C - Functions
- C - Scope Rules
- C - Arrays
- C - Pointers
- C - Strings
- C - Structures
- C - Unions
- C - Bit Fields
- C - Typedef
- C - Input & Output
- C - File I/O
- C - Preprocessors
- C - Header Files
- C - Type Casting
- C - Error Handling
- C - Recursion
- C - Variable Arguments
- C - Memory Management
- C - Command Line Arguments
- C Programming useful Resources
- C - Questions & Answers
- C - Quick Guide
- C - Useful Resources
- C - Discussion
Print colored message with different fonts and sizes in C
C/C++ programming language, the user is provided with functionality to customize the output based on the requirement of the user. C/C++ graphics functions are included in graphics.h header file. Using this library you can create different objects, set the color of text, change the font and size of the text and change the background of the output.
Now, let's see the working of all the function to alter the text of the output in c/c++ programming language −
- setcolor() − This function is used to change the color of the output text.
Syntax
setcolor(int)
Example
#include<stdio.h> #include<graphics.h> int main(){ int gdriver = DETECT,gmode,i; initgraph(&gdriver,&gmode,"C:\Turboc3\BGI"); setcolor(5); return 0; }
- settexttyle() − This function is used to change the font style, orientation, and size of the output text.
Syntax
settexttyle(int style , int orientation , int size);
Example
#include<stdio.h> #include<graphics.h> int main(){ int gdriver = DETECT,gmode,i; initgraph(&gdriver,&gmode,"C:\Turboc3\BGI"); settextstyle(3,1,4); return 0; }
- Outtext − this function is used to print the message passed to it at some certain coordinates(x,y) on the screen.
Syntax
outtext(int x_cordinate , int y_cordinate, text)
Example
#include<stdio.h> #include<graphics.h> int main(){ int gdriver = DETECT,gmode,i; initgraph(&gdriver,&gmode,"C:\Turboc3\BGI"); settextstyle(25,15,’hello!’); return 0; }
- textheight() − this function is used to change the height of the text in the output screen.
Syntax
textheight(int)
- textwidth() − This function is used to change the width of the text in the output screen.
Syntax
textwidth(int)
- Related Articles
- What are the different ways to print an exception message in java?
- Merge k sorted arrays of different sizes in C++
- Why leaves are of different shapes and sizes?
- How to make Two activities with different colored status bar in Android.
- How to capture and print Python exception message?
- C program to print characters and strings in different formats.
- How to print colored text in the console using JavaScript?
- Set different font families for screen and print with CSS
- Print 2D matrix in different lines and without curly braces in C/C++
- Display flex items vertically and reversed on different screen sizes in Bootstrap 4
- Print system time in C++ (3 different ways)
- Align flex items around on different screen sizes in Bootstrap
- How to combine list elements of different sizes in R?
- Java Program to check the birthday and print Happy Birthday message
- Haskell Program to Check the birthday and print Happy Birthday message

Advertisements