Length Of String using strlen() in C Programming Language
Definition:
- strlen() is a default function in C programming which can be used to find the length of a string.
- The input to this function should be the character array of the string whose length is to be found.
Syntax of strlen
size = strlen(String_variable);
size is int.
String_variable is char array
Example Program for Length Of String using strlen()
/*##Length Of String using strlen() In C Programing */
/*##String Programs, Datatype Programs, Basic Programs*/
/*##Example*/
// Coded By GJRS
#include <stdio.h>
#include <string.h>
int main()
{
char charArray[100];
int length;
printf("Enter the string whose length is to be found : ");
gets(charArray);
length = strlen(charArray);
printf("Length of the string is : %d",length);
return 0;
}
Output:
Enter the string whose length is to be found : Programming
Length of the string is : 11
Read More Articles
- Use of getch(),getche() and getchar() in C
- Switch Case Statement Example Program In C Programming Language
- C Character Set
- Convert a Floating-point value to an Integer in C
- Data Input and Output gets and puts Example Program In C
- Special Operators In C
- Pointer Representation and Pointer Example Programs
- C Data Input and Data Output
- Simple While Loop Example Program In C Programming Language
- Data Output printf and putchar Example Program In C
- C Introduction
- C Operators
- Storage Classes In C
- C Pointers
- File Management
- C Identifiers
- Loop Control Statements
- Hello World - Simple C Program
- C Array
- Single Character Output Function : putchar()
- C Reserve Words
- C Specific Properties and Implementation
- If else Statement Example Program In C Programming Language
- If Statement Example Program In C Programming Language
- Confusing Array in C ( Array Representation and Initialization )