Here is source code of the C program to finds the length of a string without using the built-in function..The C program is successfully compiled and run on a Linux system. The program output is also shown below.
* C program to find the length of a string without using the
* built-in function
int i, length = 0;
printf("Enter a string \n");
/* keep going through each character of the string till its end */
for (i = 0; string[i] != '\0'; i++)
printf("The length of a string is the number of characters in it \n");
printf("So, the length of %s = %d\n", string, length);
$ cc pgm52.c $ a.out Enter a string Sanfoundry The length of a string is the number of characters in it So, the length of Sanfoundry = 10
Sanfoundry Global Education & Learning Series – 1000 C Programs.
Here’s the list of Best Reference Books in C Programming, Data-Structures and Algorithms
If you liked this C Program, kindly share, recommend or like below!