Follow Us

LightBlog

Breaking

Tuesday, February 28, 2017

WAP to find the length of a string using pointer ?


WAP to find the length of a string using 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();

     }

No comments:

Post a Comment