#include<stdio.h>
int calculatelength( char * ) ;
void main( )
{
char str1[ 25 ] ;
int l;
printf ( "\n \n Pointer: Calculate the length of the string: \n " ) ; printf ( "------------------------------------------------- \n " ) ;
fgets ( str1
, sizeof str1
, stdin
) ;
l= calculatelength( str1) ;
printf ( "The length of the given string %s is : %d" , str1
, l
- 1 ) ;
}
int calculatelength( char * ch) //ch=base address of array str1 (&str1[0])
{
int ctr = 0 ;
while ( * ch != '\0 ' )
{
ctr++;
ch++;
}
return ctr;
}
I2luY2x1ZGU8c3RkaW8uaD4KaW50IGNhbGN1bGF0ZWxlbmd0aChjaGFyKik7Cgp2b2lkIG1haW4oKQp7CiAgICBjaGFyIHN0cjFbMjVdOwogICAgaW50IGw7CiAgICBwcmludGYoIlxuXG4gUG9pbnRlcjogQ2FsY3VsYXRlIHRoZSBsZW5ndGggb2YgdGhlIHN0cmluZzogXG4iKTsKICAgIHByaW50ZigiLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLSBcbiIpOwogICAgCiAgICBwcmludGYoIklucHV0IGEgc3RyaW5nOiAiKTsKICAgIGZnZXRzKHN0cjEsIHNpemVvZiBzdHIxLCBzdGRpbik7CiAgICAKICAgIGw9IGNhbGN1bGF0ZWxlbmd0aChzdHIxKTsKICAgIHByaW50ZigiVGhlIGxlbmd0aCBvZiB0aGUgZ2l2ZW4gc3RyaW5nICVzIGlzIDogJWQiLCBzdHIxLCBsLTEpOwogICAgcHJpbnRmKCJcblxuIik7CiAgICAKfQoKaW50IGNhbGN1bGF0ZWxlbmd0aChjaGFyKiBjaCkgLy9jaD1iYXNlIGFkZHJlc3Mgb2YgYXJyYXkgc3RyMSAoJnN0cjFbMF0pCnsgCiAgICBpbnQgY3RyID0gMDsKICAgIHdoaWxlICgqY2ggIT0gJ1wwJykKICAgIHsKICAgICAgICBjdHIrKzsKICAgICAgICBjaCsrOwogICAgfQogICAgcmV0dXJuIGN0cjsKfQ==