The integers generated by rand() are known as pseudo-random
. For the first call to rand(), no previous random integer exists, so the function uses a built-in integer known as the seed
A programmer can change the seed using the function srand(), as in srand(2) or srand(99
One way to get a different seed for each program run is to use the current time as the seed.
he function time() returns the number of seconds since Jan 1, 1970
The sequence will differ than if srand() was not called (which is the same as srand(1)), but that sequence will be the same for every program run.
Glasp is a social web highlighter that people can highlight and organize quotes and thoughts from the web, and access other like-minded people’s learning.