Wednesday, 18 March 2015

To find the length of the string using pointers Using C


# include <stdio.h>
# include <conio.h>

void main()
{
char *str ;
int len = 0 ;
clrscr() ;
printf("Enter a string : ") ;
scanf("%s", str) ;
while(*str != '\0')
{
len++ ;
str++ ;
}
printf("\nThe length of the string is : %d", len) ;
getch() ;
}

RUN 1 :
~~~~~~~
Enter a string : bhuvan
The length of the string is : 6

No comments:

Post a Comment