Find Length of the String in C

Length of the String in C

Here you will learn and get the program code to find the length of the String in C programming with using strlen() function and without using strlen() function. In this program you will learn to do this program by using 2 different following ways:

1. with strlen() function

2. with user defined  function

How to find string length using strlen() function

To find the length of the string, you can use the strlen() builtin function in c programming. Which is part of the string.h library.

Syntax: size_t strlen (const char * str);

For Example:

str = “CodeRevise.com

length = strlen(str);

Where str is the string whose length is to be found. The strlen() function returns the length = 14 of the string “CodeRevise.com”¬† in terms of number of characters.

Find Length of the String in C with using Strlen

Output

Length of the String in C output1

 

Find String Length without using Strlen

Output

Length of the String in C output2

 

 

 

Check out our other C programming Examples

 

 

 

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top