In this tutorial, you will learn how to calculate the length of a string in c programming language. To the better understand, you should have the basic knowledge of C programming. If you have just started learning c programming language, then check out these tutorials as well:
This program will calculate the length of a string without using any C library functions. You can also calculate the length of any string by using the C standard library function
Copy the below program and compile and run it with the help of ANSIC C.
char s, i;
printf("Please enter a string: ");
for(i = 0; s[i] != '\0'; ++i);
printf("The length of string: %d", i);
If you like FreeWebMentor and you would like to contribute, you can write an article and mail your article to [email protected] Your article will appear on the FreeWebMentor main page and help other developers.
Article Tags: c program, c program examples, c program examples with output, c programs, calculate length of string in c, length of string c, length of string in c, length of the string in c, str length in c