Find the Length of Character Array in C Last Updated : 23 Apr, 2024 Summarize Comments Improve Suggest changes Share Like Article Like Report In C, a character array is a collection of elements of the ‘char’ data type that are placed in contiguous memory locations and are often used to store strings. The length of a character array is defined as the total number of characters present in the array, excluding the null character ('\0') at the end. In this article, we will learn how to find the length of a character array in C. Example: Input: char arr[] = “Hello, Geek!” Output: Length of the character array is 12Finding the Size of a Character Array in C To find the length of a character array in C, we can directly use the strlen() function from the <string.h> library. This function returns the length of the character array, excluding the null character. Syntax to Find Length of Character Array in Cint len = strlen(arr);Note: The strlen() function even work for arrays passed to functions as it finds the length of the array using the NULL character. C Program to Find Length of Character ArrayThe below example demonstrates how we can use the strlen() function to find the the length of character array in C. C // C Program to demonstrate how to find the the length of // character array #include <stdio.h> #include <string.h> int main() { // Initializing a character array with some elements char arr[] = "Hello, Geek!"; // Finding the length of the character array int length = strlen(arr); // Printing the length of the character array printf("Length of the character array is %d\n", length); return 0; } OutputLength of the character array is 12 Time Complexity: O(N), where n is the number of characters in the character array.Auxilliary Space : O(1) Comment More infoAdvertise with us Next Article Find the Length of Character Array in C T tanya_30 Follow Improve Article Tags : C Programs C Language c-array C-Arrays C Examples +1 More Similar Reads ASCII Value of a Character in C In this article, we will discuss about the ASCII values that are bit numbers used to represent the character in the C programming language. We will also discuss why the ASCII values are needed and how to find the ASCII value of a given character in a C program.Table of ContentWhat is ASCII Value of 4 min read size of char datatype and char array in C Given a char variable and a char array, the task is to write a program to find the size of this char variable and char array in C. Examples: Input: ch = 'G', arr[] = {'G', 'F', 'G'} Output: Size of char datatype is: 1 byte Size of char array is: 3 byte Input: ch = 'G', arr[] = {'G', 'F'} Output: Siz 2 min read How to Find Size of Dynamic Array in C? In C, dynamic memory allocation allows us to manage memory resources during the execution of a program. Itâs particularly useful when dealing with arrays where the size isnât known at compile time. In this article, we will learn how to find the size of a dynamically allocated array in C. Find Size o 2 min read C program to find the frequency of characters in a string Given a string S containing lowercase English characters, the task is to find the frequency of all the characters in the string. ExamplesInput: S="geeksforgeeks" Output: e - 4 f - 1 g - 2 k - 2 o - 1 r - 1 s - 2 Input: S="gfg" Output: f - 1 g - 2Approach Follow the steps to solve the problem: Initia 2 min read How to convert given number to a character array Given an integer number N, the task is to convert it into a character array. Example: Input: N = 2020 Output: {2, 0, 2, 0} Explanation: Here char array arr[] = {2, 0, 2, 0}Input: N = 12349 Output: {1, 2, 3, 4, 9} Explanation: Here char array arr[] = {1, 2, 3, 4, 9} Approach 1: The basic approach to 14 min read Like