C Standard Libraries C++

memset()

Declaration

void* memset(void* vpDest, int iChar, size_t qCount);

Description

This function copies "qCount" chars with the value "iChar" to the buffer "vpDest." The function returns the pointer "vpDest."

Example

#include <cstdio>
#include <cstring>

int main()
{
    char caDest[] = "XoaX.net";

    printf("Before Memset: %s\n", caDest);
    // Make the first chars 'T'
    memset(caDest, 'T', 4);
    printf("After Memset: %s\n", caDest);

    return 0;
}

Output

memset() Output
 

© 2007–2024 XoaX.net LLC. All rights reserved.