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);
Prem Tiwari is the founder of FreeWebMentor.com and also a professional developer who has vast experience in PHP and open source technologies. Apart from this, he is a blogger by hobby and also he has been a regular speaker of WordPress sessions in various IT Companies. View all posts by Prem Tiwari