Sunday, 6 January 2019

Filled Under:

Length of string using Pointer in c[c programming examples with output]

C programming examples with output

Length of string using Pointer
Program

#include<stdio.h>
int string_In(char*);
void main()
{
      char str[20];
      int length;
      printf("\nEnter any string: ");
      gets(str);
      length=string_In(str);
      printf("The length of the given string %s is: %d",str,length);
}
      int string_In(char*p)
{
      int count=0;
      while(*p!='\0'){
      count++;
      p++;
}
return count;
}

Output:
Enter any string: programming
The length of the given string programming is: 11

0 komentar:

Post a Comment