By: Prem Tiwari | Last Updated:
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);