pages

Friday, 21 May 2021

c-program to calculate the length of string using pointer | c-programing

 Program to calculate the length of string using pointer in c-programming

In this program , we will now taking  input as a string and calculate the length of string by using pointer.

pointer : pointer is a variables that stores address of another variables.

#include<stdio.h>
#include<conio.h>
void main()
{
         char str[50];
         char *i,count=0;
         i=str;
         printf("enter the string:-");
         gets(str);
         while(*i!='\0'){
                  count++;
                  i++;
         }
         printf("\n the length of the string is %d:-",count);
         getch();
}

output:-



For more c-programming:-















No comments:

Post a Comment