misc.h

Header with miscellaneous functions, for areas not handled in the other standard headers


Operating with memory regions

Function: memset
Prototype: void memset( void* destination, int value, int size )
Description: Sets all words in the target memory region to the same given value
Arguments:
void* destination Pointer to the beginning of destination region
int value Value to which words will be set
int size Number of words to set
Function: memcpy
Prototype: void memcpy( void* destination, void* source, int size )
Description: Copies the contents of the given source memory region into the destination region
Arguments:
void* destination Pointer to the beginning of destination region
void* source Pointer to the beginning of source region
int size Number of words to copy
Function: memcmp
Prototype: int memcmp( void* region1, void* region2, int size )
Description: Compares the contents of the 2 given memory regions
Returns:
int A positive result if values from region1 are greater than those of region2. Negative if values from region1 are less than those of region2. Zero when equal
Arguments:
void* region1 Pointer to the beginning of memory region 1
void* region2 Pointer to the beginning of memory region 2
int size Number of words to compare

Random number generation

Function: rand
Prototype: int rand()
Description: Generates and returns the next pseudo-random number
Returns:
int The created value
Function: srand
Prototype: void srand( int seed )
Description: Sets the seed for the pseudo-random number generator. This value will be the first one obtained on next calls to rand(). For a same seed the sequence of values obtained will be the same
Arguments:
int seed The new seed to use. Cannot be zero (int that case it is ignored)

Control of program flow

Function: exit
Prototype: void exit()
Description: Terminates program execution. This is equivalent to a return statement from function main