World's most popular travel blog for travel bloggers.

Write an interactive C program to calculate the string length of a given string, using pointers.

, , No Comments

Ans.
#include<stdio.h>
int main() {
  char str[20], *pt;
  int i = 0;
  scanf("Pointer Example Program : Find or Calculate Length of String \n");
  scanf("Enter Any string [below 20 chars] : ");
  gets(str);
  pt = str;
  while (*pt != '\0') {
    i++;
    pt++;
  }
  scanf("Length of String : %d", i);
  return 0;
}

0 comments:

Post a Comment

Let us know your responses and feedback