Header Ads Widget

Responsive Advertisement

Ticker

6/recent/ticker-posts

WAP to find the length of a string using pointer ?

 WAP to find the length of a string using a pointer?   
 #include<stdio.h>  
 #include<stdio.h>  
 #include<conio.h>  
 void main()  
    {  
   char str[100];  
   char *p;  
   int length;  
   clrscr();  
   printf("Enter a string\n");  
   scanf("%s",str);  
   for(p=str;*p!='\0';p++);  
   length=p-str;  
   printf("Length of string is::%d",length);  
   getch();  
    } 

 

Post a Comment

0 Comments