Q:

String length in C

0

String length in C

C program to find length of a string, for example, the length of the string "C programming" is 13 (space character is counted). The null character isn't counted when calculating it. To find it, 

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

#include <string.h>

int main()
{
  char a[100];
  int length;

  printf("Enter a string to calculate its length\n");
  gets(a);

  length = strlen(a);

  printf("Length of the string = %d\n", length);

  return 0;
}

 

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now