Share this page

# strlen

String Manipulation Functions

Returns the length (in bytes) of a string.

    size_t strlen( const char *string);

string | The string whose length is returned.

## Return Values

strlen returns the length (in bytes) of a string.

## Example

The following example loops through a string, str, in search of the first non-numeric character. strlen ascertains the length, len, of str. If the while loop has iterated len times, indicating the end of the string, then the loop terminates with a return statement.

Copy code

        #include <string.h>
        int is_digit, i = 0;
        char * str = "1234567k89";
        unsigned int len = strlen(str);
        do {
            if (i == len) {
                lr_output_message ("No letters found in string");
                return -1;
            }
            is_digit = isdigit(str[i++]);
        }
        while (is_digit);
            lr_output_message ("The first letter appears in character %d of string", i);}

    Example: Output:
    Action.c(18): The first letter appears in character 8 of string

Tips to improve your search results... VuGen Function Reference Version 26.1-26.3 Function Reference 26.1-26.3 All View Local Help Center View Online Help Center Version: