strlen()                 Get String Length
 
 #include   <string.h>
 
 int          strlen(string);            Required for declarations only
 char          *string;
 
    strlen() gets the length of 'string'. The terminating null character
    ('\0') is not included in the length.
 
    Returns:    The string length.  A length of zero means the string is
                empty.  There is no error return.
 
  -------------------------------- Example ---------------------------------
 
    This example makes sure 'string2' is not empty before copying it to
    'string1'.
 
          #include <string.h>
          #include <stdio.h>
 
          char string1[50];
          char string2[50] = "bumble bee";
          int len;
 
          main()
          {
                if ((len = strlen(string2)) > 0)
                   strcpy(string1,string2);
                printf("%s",string1);
          }

Seealso:



This page last updated on Fri Nov 30 10:48:32 MSK 2001
Copyright © 1992-2001, Vitaly Filatov, Moscow, Russia
Webmaster