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);
}
Post A Comment:
0 comments: