Aug 28, 2026 — Digital Edition
Bradley Ideas
Independent Journalism & Insight
Feature

How to Print a Char Array in C

Mastering string manipulation in C often involves dealing with character arrays (char arrays). To print a char array in C, you can utilize several methods. This article will delve into the most straightforward and efficient ways to accomplish this task.

Array vs Pointer in C 😳 (Simple Beginner Guide)
Array vs Pointer in C 😳 (Simple Beginner Guide)

Printing a char array in C is fundamental to any string-related operations. Whether you're reading a file, handling user input, or crafting your own string functions, knowing how to print a char array is a crucial skill.

an image of a computer screen with some text on it and another screenshote in the background
an image of a computer screen with some text on it and another screenshote in the background

Printing Using printf

The most common method to print a char array in C is by using the printf function. This versatile function allows you to format output strings, including printing char arrays.

a row of blue lockers with the words c in front of it and an image of
a row of blue lockers with the words c in front of it and an image of

To utilize printf to print a char array, you need to ensure the array's null terminator is included, as C string functions like printf use the null terminator to determine the string's length.

Using %s Format Specifier

C Arrays Cheat Sheet (1D, 2D Arrays, Syntax, Examples & Programs)
C Arrays Cheat Sheet (1D, 2D Arrays, Syntax, Examples & Programs)

The %s format specifier in the printf function is designed to print a string (or char array). To use this specifier, include it in your format string and pass the char array as an argument.

char str[] = "Hello, World!";\nprintf("The string is: %s\n", str); This will output: The string is: Hello, World!

Using %c Format Specifier

Pointers and Arrays in C Tutorial – Comprehensive Guide PDF
Pointers and Arrays in C Tutorial – Comprehensive Guide PDF

If you want to print the char array character by character, you can use the %c format specifier in a loop. This method is useful when you need to observe the individual characters of a char array.

char str[] = "Hello, World!";\nfor (int i = 0; i < strlen(str); i++) {\n printf("Character at index %d is: %c\n", i, str[i]);\n} This will output each character and its index.

Printing Using puts

C++ program to read and display characters of an array - Codeforcoding
C++ program to read and display characters of an array - Codeforcoding

Another way to print a char array in C is to use the puts function. This function prints a string (or char array) followed by a newline character.

char str[] = "Hello, World!";\nputs(str); This will output: Hello, World!

an image of a computer screen with some text on it and the same line of code
an image of a computer screen with some text on it and the same line of code
ARRAYS - Learn C Programming Language (Computer Science Engineering) | Handwritten Aesthetic Notes
ARRAYS - Learn C Programming Language (Computer Science Engineering) | Handwritten Aesthetic Notes
Learn Arrays in C++ in 10 minutes.
Learn Arrays in C++ in 10 minutes.
Multi-Dimensional Arrays in C#
Multi-Dimensional Arrays in C#
C Program to Print Floyd’s Triangle
C Program to Print Floyd’s Triangle
Array Initialization in C++
Array Initialization in C++
Arrays in Embedded C: Complete Guide with Examples
Arrays in Embedded C: Complete Guide with Examples
C Programming Tutorial: Pointers and Arrays
C Programming Tutorial: Pointers and Arrays
What are arrays in C Programming? - UseMyNotes
What are arrays in C Programming? - UseMyNotes

Now that you've learned multiple methods to print a char array in C, you're ready to harness your newfound skills. Whether you're starting a new project or solving algorithmic problems, knowing how to print a char array is an essential part of your C language toolkit. So go ahead, start practicing, and happy coding!