[an error occurred while processing this directive]

C String length

                         

In this section, you will learn how to determine the length of a String in C. You can see in the given example, we have declared a string and initialize a variable i to 0. The while loop will increment the value of i till it reach the string terminating character or up to the last letter of the string value.

Here is the code:

StringLen.c

#include <stdio.h>
#include <conio.h>
void main() {
  char str[] "Hello World";
  int i=0;
  while (str[i!= 0)
 
    i++;
  printf("\nThe length of the string \"%s\" is %d.", str, i);
  getch();
}

Output will be displayed as:

Download Source Code:

                         

[an error occurred while processing this directive]