nld Manual
Sample nld and noft Session
nld Manual—528272-001
A-6
User Library UTILC
User Library UTILC
The user library UTILC contains the seed_random_number function. This function
gets the current time, converts it to a time structure, and multiplies the minutes by the
seconds to seed the random number generator.
Compilation Commands
Compile the source modules MAINC, MODULE1C, and MODULE2C with these
commands:
NMC /IN MAINC, OUT MAINL / MAINO; OPTIMIZE 0, SYMBOLS
NMC /IN MODULE1C, OUT MODULE1L/ MODULE1O;OPTIMIZE 0, SYMBOLS
NMC /IN MODULE2C, OUT MODULE2L/ MODULE2O;OPTIMIZE 0, SYMBOLS
Compile the user library UTILC with this command:
NMC /IN UTILC, OUT UTILL / UTILO; OPTIMIZE 0, SYMBOLS, SRL
The only difference for compiling the user library is the inclusion of the pragma SRL.
Example A-8. User Library UTILC With Edit Line Numbers
1 #pragma nolist
1.1 #include <stdlibh>
2 #include <timeh>
3 #pragma list
3.1 #include "util.h"
4
5 void seed_random_number(void)
5.001 /*
5.01 * Increase randomness of rand() by setting
5.02 * srand(seed) with values from time.
5.1 */
6 {
7 time_t now;
9 struct tm *time_ptr;
10
11 now = time(NULL);
12 time_ptr = localtime(&now);
13 srand(time_ptr->tm_sec * time_ptr->tm_min);
18 } /* seed_random_number */