Share this page

# memchr

String Manipulation Functions

Searches for a character in a buffer.

    void *memchr( const void *s, int c, size_t n);

s | The name of the buffer.
c | The character to search for in the buffer.
n | The number of characters at the beginning of the buffer to search.

## Return Values

A pointer to the first occurrence of c in buffer. If character is not found the function returns NULL.

For memchr details, refer to your C language documentation.

## Example

The following example searches for the character `x' in the string "Example string".

        #include <string.h>

        char * p;
        char str[] = "Example string";
        p = (char *)memchr(str, 'x', strlen(str));
        if (p)
            lr_output_message ("Character x is at position %d\n", p - str + 1);
        else
            lr_output_message ("Character x was not found");

    Example: Output:

    Character x is at position 2

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