beautypg.com

Srand function, Strcat function – Zilog Z80380 User Manual

Page 77

background image

UM004001-COR1103

4–13

Run Time Environment

Library Functions

srand

FUNCTION

Header file statement:

#include

Syntax:

void srand

( unsigned int seed);

The srand function sets the starting point for generating a series of pseudorandom integers.
To reinitialize the generator, use 1 as the seed argument. Any other value for seed sets the
generator to a random starting point.

The rand function is used to retrieve the pseudorandom numbers that are generated. Calling
rand before any call to srand generates the same sequence as calling srand with seed passed
as 1.

Return Value

There is no return value.

strcat

FUNCTION

Header file statement:

#include

Syntax:

char *strcat

(char *string1, const char *string2);

The strcat function appends string2 to string1, terminates the resulting string with a null char-
acter, and returns a pointer to the concatenated string (string1).

The strcat function operates on null-terminated strings. The string arguments to this function
are expected to contain a null character (‘\0’) marking the end of the string. No overflow
checking is performed when strings are copied or appended.

Return Value

The return values for this function are described above.

Parameter

Description

seed

Seed for random-number generation

Parameter

Description

string1

Destination string

string2

Source string