How and when to Use the cprintf() Function

Conio.h in C and C++ is one of the libraries that have a set of functions allowing for interacting with the console and, therefore, expanding the opportunities of console applications. The function that I want to discuss, cprintf, is closely connected with the question above because it can be used with arguments that are strings. At first, the cprintf function’s syntax will be presented, then, I will describe how to use the function, and finally, I will present several examples when the function cprintf should be applied in practice.

Overview of conio.h

conio.h stands for console input/output. Among C and C++, it is widely used for functions suited to DOS-based systems, as well as early Windows environments. It contains functions for handling console I/O, including reading keyboard input, manipulating text, and controlling the cursor.

The cprintf Function

The cprintf function is used for formatted console output, similar to printf, but with enhanced capabilities for console-specific text manipulation. When we use textcolor() and textbackground() to change the color of the console, we have to use cprintf() instead of printf() is see the desired formatted output.

Syntax of cprintf()

int cprintf(const char *format, ...);


  • format: A format string that specifies how to format the subsequent arguments.
  • … : The variables to be formatted and printed according to the format string.


#include <conio.h>

int main() {


    cprintf("Coding Dots...");

    return 0;


Related Post

Leave a Reply

Your email address will not be published. Required fields are marked *

The reCAPTCHA verification period has expired. Please reload the page.