C program to calculate the string length of a given string,using pointer
Answers
Answered by
2
#include<stdio.h>
int main()
{
char str[20], *ptr;
int i = 0;
printf("Enter Any string ");
gets(str);
ptr = str;
while (*ptr!= '\0')
{
i++;
ptr++;
}
printf("Length of String : %d", i);
return 0;
}
int main()
{
char str[20], *ptr;
int i = 0;
printf("Enter Any string ");
gets(str);
ptr = str;
while (*ptr!= '\0')
{
i++;
ptr++;
}
printf("Length of String : %d", i);
return 0;
}
Similar questions