Syntax, Example, Memccpy( ) function – Echelon Neuron C User Manual

Page 128

Advertising
background image

108

Functions

Table 30. Result Types for the max() Function

Larger Type

Smaller Type

Result

unsigned long (any)

unsigned long

signed long

signed long
unsigned short

signed short

signed long

unsigned short

unsigned short

signed short

unsigned short

signed short

signed short

signed short

If the result type is unsigned, the comparison is unsigned, else the comparison is

signed. Arguments can be cast, which affects the result type. When argument
types do not match, the smaller type argument is promoted to the larger type

prior to the operation.

Syntax

type

max (

a

,

b

);

Example

int a, b, c;
long x, y, z;

void f(void)
{

a = max(b, c);

x = max(y, z);

}

Note: The description of the max() function result types and type promotion of

arguments also applies equally to the min() function.

memccpy( )

Function

The memccpy( ) function copies

len

bytes from the memory area pointed to by

src

to the memory area pointed to by

dest

, up to and including the first occurrence of

character

c

, if it exists. The function returns a pointer to the byte in

dest

immediately following

c

, if

c

was copied, else memccpy( ) returns NULL. This

function cannot be used to write to EEPROM or flash memory. See also
ansi_memcpy( ), ansi_memset( ), eeprom_memcpy( ), memchr( ), memcmp( ),

memcpy( ), and memset( ).

Syntax

#include <mem.h>
void* memccpy (void *

dest

, const void *

src

, int

c

, unsigned long

len

);

Advertising