C strlen( ) function

  • By using this predefined function we can find the length of the string.
  • strlen() requires one argument of type constant char* i.e. an address of a string.
  • Syntax:

    int strlen(const char* src);

  • When we are working with strlen() from given address upto null, entire content will counts and that total number of characters returns as length.
  • Length of the string means total number of characters excluding null.

Example:

#include
#include
#include
int main()
{
char s[]=”K2schools”;
int s,l;
puts(str);
l=strlen(str);
s=sizeof(tr);
pritnf(“\n length of string %d”,l);
pritnf(“\n size of string %d”,s);
getch();
return 0;
}

Powered by k2schools