Length of string using Pointer - C - A6P7



/* Write a program to find the Length of string using Pointer */

#include<stdio.h>
#include<conio.h>
void main()
{
    int len;
    char *str1,*str2;
    clrscr();
    printf("Enter The string -> ");
    gets(str1);
    str2=str1;
    while(*str1 != NULL)
    {
        str1++;
    }
    len=str1-str2;
    printf("\nLength of string -> %d",len);
    getch();
}

Post a Comment