Header Ads Widget

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("%d\n",length(str));
getch();
}

// function defenation length
int length(char *p)
{
int l;
for(l=0;*(p+l)!='\0';l++);
return l;
}

Post a Comment

0 Comments