Write a C program to find the length of string using pointers.

Program Code:
#include<stdio.h>
#include<string.h>
void main()
{
char a[10],*ptr;
int i=0;
printf("\n enter a string: ");
gets(a);
ptr=a;
while(*ptr!='\0')
{
i++;
ptr++;
}
printf("\n length of a string is %d",i);
}
Mukesh Rajput

Mukesh Rajput

I am a Computer Engineer, a small amount of the programming tips as it’s my hobby, I love to travel and meet people so little about travel, a fashion lover and love to eat food, I am investing a good time to keep the body fit so little about fitness also..

Post A Comment:

0 comments: