C Program to Find the Length of a String without using the Built-in Function
This C Program finds the length of a string without using the built-in function. This program is used to find the length of the string means total number of characters present in a given string. This program need to be done without using the built-in-function. The built in functions are those which have built- in already which can be used directly.
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
Enter a string
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.
If you liked this C Program, kindly share, recommend or like below!
Manish Bhojasia, a technology veteran with 17+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He is Linux Kernel Developer and SAN Architect and is passionate about competency developments in these areas. He lives in Bangalore and delivers focused training sessions to IT professionals in Linux Kernel, Linux Debugging, Linux Device Drivers, Linux Networking, Linux Storage & Cluster Administration, Advanced C Programming, SAN Storage Technologies, SCSI Internals and Storage Protocols such as iSCSI & Fiber Channel. Stay connected with him below.