🌐
GeeksforGeeks
geeksforgeeks.org › c language › printf-in-c
printf in C - GeeksforGeeks
The printf() function is defined inside <stdio.h> header file. ... formatted_string: It is a string that specifies the data to be printed. It may also contain a format specifier as a placeholder to print the value of any variable or value.
Published   October 18, 2025
🌐
TutorialsPoint
tutorialspoint.com › c_standard_library › c_function_printf.htm
C Library - printf() function
#include <stdio.h> int main() { // Octal representation of 61 int octal_num = 075; // Hexadecimal representation of 31 int hex_num = 0x1F; printf("Octal: %o, Hexadecimal: %X\n", octal_num, hex_num); return 0; } After execution of above code, ...
People also ask

Is printf a keyword in C?
No, printf is not a keyword in C. It is a function defined in the standard input/output library (stdio.h).
🌐
wscubetech.com
wscubetech.com › resources › c-programming › printf
printf() in C Programming (Syntax, Examples, How to Use?)
What is the difference between print and printf in C?
C only has printf; there is no print function in C. printf allows formatted output, unlike simpler print functions in other languages.
🌐
wscubetech.com
wscubetech.com › resources › c-programming › printf
printf() in C Programming (Syntax, Examples, How to Use?)
Can I display output in C without using printf()?
Yes, you can use functions like puts() or putchar() to display output, but they are less flexible because they do not support formatted printing like printf().
🌐
wscubetech.com
wscubetech.com › resources › c-programming › printf
printf() in C Programming (Syntax, Examples, How to Use?)
🌐
WsCube Tech
wscubetech.com › resources › c-programming › printf
printf() in C Programming (Syntax, Examples, How to Use?)
March 10, 2026 - Learn in this tutorial printf() in C, its Syntax, examples, and usage explained. Master this essential function to format and display output effectively in C.
🌐
Educative
educative.io › answers › how-to-use-printf-in-c
How to use printf in C
printf (print formatted) in C, writes out a cstring to stdout (standard output).
🌐
Codecademy
codecademy.com › docs › basic output › printf()
C | Basic Output | printf() | Codecademy
May 29, 2025 - Some common ones are shown below: When using format specifiers for decimal numbers, the number of decimal places to be printed can be specified. For example, to print two digits after the decimal place with printf(), 0.2f can be used:
🌐
W3Schools
w3schools.com › c › ref_stdio_printf.php
C stdio printf() Function
char var1 = 102; short int var2 = 2024; int var3 = 95; long int var4 = 212; long long int var5 = 1200L; printf("%hhd %hd %d %ld %lld", var1, var2, var3, var4, var5); Try it Yourself »
🌐
CodeChef
codechef.com › blogs › output-in-c
C printf function (Example and Practice)
August 6, 2024 - You need to enable JavaScript to run this app
🌐
R-bloggers
r-bloggers.com › r bloggers › mastering printf() in c: a beginner’s guide
Mastering printf() in C: A Beginner’s Guide | R-bloggers
September 18, 2024 - For instance, to print a string followed by a character: ... Escape sequences in printf() are special characters preceded by a backslash, used to format the output:
Find elsewhere
🌐
TutorialsPoint
tutorialspoint.com › cprogramming › c_printf_function.htm
printf() Function in C
It can print text, numbers, characters, variables and even formattted data. For example, writing "Hello, World!" inside the printf() function will display exactly that on the screen.
🌐
NV5 Geospatial Software
nv5geospatialsoftware.com › docs › Format_Codes_CPrintf.html
C printf-Style Format Codes
View our Documentation Center document now and explore other helpful examples for using IDL, ENVI and other products.
🌐
Vaia
vaia.com › c printf
C Printf: Format Specifiers & Techniques | Vaia
The basic structure of a printf function involves specifying the format string, which may include literal text and format specifiers. Here's what the function call looks like: ... The argument_list is optional but used when the format string contains specifiers requiring variable input. ... This example casts the integer year into the output format string using %d as the format specifier.
🌐
W3Resource
w3resource.com › c-programming › c-printf-statement.php
C printf() function - w3resource
April 9, 2026 - C uses escape sequences within a format string to print certain special characters. For example \n moves the output position to the beginning of the next line. The following is a list of escape sequences.
🌐
Medium
medium.com › @abenapomaa › understanding-the-printf-function-in-c-18a2fe2fffa5
UNDERSTANDING THE printf FUNCTION IN C | by Abena Pomaa | Medium
July 13, 2023 - printf(“hello”); prints the simple text, hello. However, an elaborate use of the function takes an argument, then a list of values separated by comma(s) to match their associated format specifiers in the string. ... Example 1.
🌐
HowStuffWorks
computer.howstuffworks.com › tech › computer software › programming
Printf: Reading User Values - The Basics of C Programming | HowStuffWorks
March 8, 2023 - In the printf statement, it is ... the variables following it. For example, if the format string contains three %d operators, then it must be followed by exactly three parameters ......
🌐
ZetCode
zetcode.com › clang › printf
C printf Tutorial: Master Formatted Output with Practical Examples
April 6, 2025 - Here, printf outputs the string "Hello, World!" followed by a newline character. The \n escape sequence moves the cursor to the next line. This basic example shows how to print static text without variables.
Top answer
1 of 2
3

While it looks different in your editor, it's actually the same.

When you write

printf("Hello, World!\n");

in your editor, your compiler in principle change it to

char* hidden_unnamed_string = "Hello, World!\n";
printf(hidden_unnamed_string);

The string "Hello, World!\n" is called a string literal. The compiler will (automatically) place it somewhere in memory and then call printf with that memory address.

Here is an example from godbolt.org

On the left side you have the C program as it looks in your editor. To the right you have the compiled program.

Notice how the string is located outside the code block and labeled with LC0. Then inside the code block LC0 is loaded into edi (i.e. the address of/pointer to the string is loaded into edi) just before calling the printing function.

Also notice that the compiler decided to use puts instead of printf. Further notice that the string is stored without the \n. The reason is that puts unlike printf automatically adds a \n.

2 of 2
0

For starters instead of this call of printf

printf("Hello, World!\n");

you could use a call of puts like

puts( "Hello, World!" );

The string literal "Hello, World!\n" internally is represented as a character array like

char string_literal[] = 
{ 
    'H', 'e', 'l', 'l', 'o', ',', ' ', 'W', 'o', 'r', 'l', 'd', '!', '\n', '\0' 
};

Arrays used in expressions are implicitly converted (with rare exceptions) to pointers to their first elements.

So in this call

printf("Hello, World!\n");

the character array used as an argument of the function call is converted to pointer of the type char * to its first element 'H'. You can imagine that the following way

printf( &"Hello, World!\n"[0] );

Thus the function deals with a pointer of the type char *. You could do the same by introducing an intermediate variable

char *s = "Hello, World!\n";
printf( s );

or

char *s = "Hello, World!\n";
printf( "%s", s );

or

char *s = "Hello, World!";
printf( "%s\n", s );

or

char *s = "Hello, World!";
puts( s );
🌐
Cplusplus
cplusplus.com › reference › cstdio › printf
Printf
<cstdio> printf · function · <cstdio> int printf ( const char * format, ... ); Print formatted data to stdout · Writes the C string pointed by format to the standard output (stdout).
🌐
TechOnTheNet
techonthenet.com › c_language › standard_library_functions › stdio_h › printf.php
C Language: printf function (Formatted Write)
printf("%s is over %d years old and pages load in %.1f seconds.\n","TechOnTheNet.com",10,1.4); Result: TechOnTheNet.com is over 10 years old and pages load in 1.4 seconds. Let's look at an example to see how you would use the printf function in a C program:
🌐
Log2Base2
log2base2.com › C › basic › printing-value-of-a-variable.html
Printing variables using printf | format specifiers in c
In order to print the variable ... name which we want to print. Example · #include<stdio.h> int main() { int i = 10; char c = 'a'; printf("Value of i = %d\n",i); printf("Value of c = %c\n",c); return 0; } Run it ·...