![]() |
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 ( Example: Input: char arr[] = “Hello, Geek!” Output: Length of the character array is 12 Finding the Size of a Character Array in CTo find the length of a character array in C, we can directly use the Syntax to Find Length of Character Array in Cint len = strlen(arr);
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.
Output Length of the character array is 12 Time Complexity: O(N), where n is the number of characters in the character array. |
Reffered: https://www.geeksforgeeks.org
C Language |
Related |
---|
![]() |
![]() |
![]() |
![]() |
![]() |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 15 |