Share with your friends
Call

How to Print in C / C++ Programming

Printing is one of the most basic features used for debugging programs. C/C++ programming languages allow you to print output to the console window. Here are two easy ways to print output when programming in C/C++.

Method 1: use the \ printf() \ function

The \ printf() \ function is designed to display output according to instructions provided in its parameter. It prints the formatted string passed in the parentheses of the function, followed by any specified variable values. Here is an example of how to print a string using the \ printf() \ function:

printf("Hello World!\n");

Method Two: use the \ fprintf() \ function

The \ fprintf() \ function is designed to write formatted output to a text file, instead of the console window. Both functions follow the same syntax, but \ fprintf() \ allows you to specify a text file instead of the standard output file. Here’s an example:

fprintf(stdout, "Hello World!\n");