Thursday 14 May 2015

A function to calculate length of string

The following function will calculate the length of a given string
int strlength(char *s)
{
      int len=0;
      while(s[len])  //repeat until a null character is found
            ++len;
      return len;
}

No comments:

Post a Comment