Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Turbo C - <b>strlen() get string length</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
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);
          }

See Also:

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson