Program to calculate length of a string by using pointer..

int length(char *); // function decleration
main()
{
char str[17];
clrscr();
scanf(“%[^n]”,str); // input string
printf(“%dn”,length(str));
getch();
}


// function defenation length

int length(char *p)
{
int l;
for(l=0;*(p+l)!=0;l++);
return l;
}


One thought on “Program to calculate length of a string by using pointer..

Leave a Reply

Your email address will not be published.