Programming in "C‟ | Write a „C‟ program to count length of the string using pointer.

 (Note: Any other correct logic shall be considered).

#include<stdio.h>

#include<conio.h>

void main() {

char ar[50];

char *s;

int l=0;

clrscr();

printf("enter a string");

scanf("%s",ar);

s=ar;

while(*s!='\0'){

l++;

s++;

}

printf("Length of th string is %d",l);

getch();

}


Post a Comment

0 Comments