11.07.2015 Views

PicC 9.50 dsPIC Manual.pdf

PicC 9.50 dsPIC Manual.pdf

PicC 9.50 dsPIC Manual.pdf

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Library FunctionsSRANDSynopsis#include void srand (unsigned int seed)DescriptionThe srand() function initializes the random number generator accessed by rand() with the givenseed. This provides a mechanism for varying the starting point of the pseudo-random sequenceyielded by rand(). On the z80, a good place to get a truly random seed is from the refresh register.Otherwise timing a response from the console will do, or just using the system time.Example#include #include #include voidmain (void){time_t toc;int i;}time(&toc);srand((int)toc);for(i = 0 ; i != 10 ; i++)printf("%d\t", rand());putchar(’\n’);See Alsorand()196

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!