c program string funtion



C Program to Find the Length of a String without using the Built-in Function


This is a C program to find the length of a string without using the built-in function.
Problem Description
This program takes a string as input and finds its length without using the built-in function.
Problem Solution
1. Take a string as input and store it in the array.
2. Using for loop count the number of characters in the array and store the result in a variable.
3. Print the variable as output.
Program/Source Code
Here is source code of the C program to find 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.



Required knowledge



program : 


#include<stdio.h>

int main()

{

    char str1[100]="atikur rahman";


       int i,j,len;
    ///len=0;
        for(len=0;str1[len]!='\0';len++);

    printf("length : %d",len);
}








 output :









No comments

Powered by Blogger.