Older Newer
Fri, 17 Jan 2020 04:41:24 . . . . SyneRyder [Function definition]


Changes by last author:

Added:
= memset =

== Syntax ==

void* memset(void *dest, int val, int n)

== Arguments ==

:dest

::The memory block to copy data to

:val

::The value that all the bytes in the memory block will be set to, up to the provided length

:n

::The number of bytes to be set

== Return ==

Returns a pointer to the destination (dest) memory block.

== Description ==

memset sets each byte in the memory block to the given value/character, up to the number of bytes given.

== Example ==

<code>

%fml

OnFilterStart: {

// Allocate 1000 bytes of memory

char* strbuffer;

strbuffer = malloc(1000);

// Fill the memory block with zeros

memset(strbuffer, 0, 1000);

// Set short lengths to a letter,

// progressively overwriting them

memset(strbuffer, 'e', 10);

memset(strbuffer, 'D', 8);

memset(strbuffer, 'c', 6);

memset(strbuffer, 'B', 4);

memset(strbuffer, 'a', 2);

// Prints 'aaBBccDDee'

printf("%s", strbuffer);

// Release the memory again

free(strbuffer);

return true;

}

</code>

== See Also ==

free, strncpy, strcpy, malloc