Contact Learn C
Copy

Prog 189:To print length of a string using Pointers

Program 189:
 
 #include<stdio.h>
main()
{
  char s[25],*t;
  int len=0;
  printf("Enter a string\n");
  scanf("%s",&s);
  t=s;//copying base address of string
  while(*t!='\0')
  {
   len++;
   t++;
  }
  printf("length of string is %d\n",len);
}


Explanation:

//Coming Soon...

Output:

To print length of a string using Pointers







 
Donate

Download App and Learn when ever you want

Get it on PlayStore
Get it on Amazon App Store
Get it on Aptoide