Syntax, Example, Memcpy( ) built-in function – Echelon Neuron C User Manual

Page 130: Memset( ) built-in function

Advertising
background image

110

Functions

Syntax

#include <mem.h>

int memcmp (void *

buf1

, const void *

buf2

, unsigned long

len

);

Example

#include <mem.h>

unsigned array1[40], array2[40];

void f(void)
{

// See if array1 matches array2

if (memcmp(array1, array2, sizeof(array1)) != 0) {

// The contents of the two areas does not match

}
}

memcpy( )

Built-in Function

The memcpy( ) built-in function copies a block of

len

bytes from

src

to

dest

. It

does not return any value. This function cannot be used to copy overlapping

areas of memory, or to write into EEPROM or flash memory. The memcpy( )
function can also be used to copy to and from the data fields of the msg_in,

resp_in, msg_out, and resp_out objects.
The memcpy( ) function as implemented here does not conform to the ANSI C
definition, because it does not return a pointer to the destination array. See

ansi_memcpy( ) for a conforming implementation. See also ansi_memset( ),

eeprom_memcpy( ), memccpy( ), memchr( ), memcmp( ), and memset( ).

Syntax

void memcpy (void *

dest

, void *

src

, unsigned long

len

);

Example

void f(void)
{

memcpy(msg_out.data, "Hello World", 11);

}

memset( )

Built-in Function

The memset( ) built-in function sets the first

len

bytes of the block pointed to by

p

to the character

c

. It does not return any value. This function cannot be used to

write into EEPROM or flash memory.
The memset( ) function as implemented here does not conform to the ANSI C
definition, because it does not return a pointer to the array. See ansi_memset( )

for a conforming implementation. See also ansi_memcpy( ), eeprom_memcpy( ),

memccpy( ), memchr( ), memcmp( ), and memcpy( ).

Advertising