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 FunctionsRANDSynopsis#include int rand (void)DescriptionThe rand() function is a pseudo-random number generator. It returns an integer in the range 0to 32767, which changes in a pseudo-random fashion on each call. The algorithm will produce adeterministic sequence if started from the same point. The starting point is set using the srand() call.The example shows use of the time() function to generate a different starting point for the sequenceeach 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 Alsosrand()185

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

Saved successfully!

Ooh no, something went wrong!