Share this page

# memset

Buffer Manipulation Functions

Sets n bytes of a buffer to a given character.

    void *memset( void *buffer, int c, size_t n);

buffer | Pointer to block of data to be filled with c.
c | The character placed in buffer.
n | The number of bytes in buffer set as c.

## Return Values

Returns buffer, pointer to block of data to be filled with c.

For memset details, refer to your C language documentation.

## Example

The following example uses memset to fill a structure, about_app, with zeros, before initializing it.

Copy code

    #include <string.h>
    struct about_app {
    char *version;
    int field1;
    int field2;
    };
    // Global scope
    struct about_app a;
    a.field1 = 12;
    a.field2 = 13;
    // Set all fields to 0
    memset(&a, 0, sizeof(struct about_app));
    // Show that fields are set to 0
    lr_output_message("After memset field1=%d field2=%d", a.field1, a.field2);
    // Initialize the structure
    a.version = "app version 1.0";
    a.field1 = 5;
    a.field2 = 6;
    lr_output_message("Now, field1=%d field2=%d", a.field1, a.field2);

    Example: Output:
    Action.c(18): After memset field1=0 field2=0
    Action.c(23): Now, field1=5 field2=6

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: