Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Microsoft C 6.0 - <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>

 size_t  strlen(string);                 Required for declarations only
 const char    *string;

    strlen() gets the length of 'string'. The terminating null character
    ('\0') is not included in the length.

    Returns:    The string length; no error return.  A length of zero
                means the string is empty..

   -------------------------------- 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);
           }




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