User manual
MPLAB
®
XC8 C Compiler User’s Guide
DS52053B-page 360 2012 Microchip Technology Inc.
SRAND
Synopsis
#include <stdlib.h>
void srand (unsigned int seed)
Description
The srand() function initializes the random number generator accessed by rand()
with the given
seed. This provides a mechanism for varying the starting point of the
pseudo-random sequence yielded by rand().
Example
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
void
main (void)
{
time_t toc;
int i;
time(&toc);
srand((int)toc);
for(i = 0 ; i != 10 ; i++)
printf("%d\t", rand());
putchar(’\n’);
}
See Also
rand()
SSCANF, VSSCANF
Synopsis
#include <stdio.h>
int sscanf (const char * buf, const char * fmt, ...)
#include <stdio.h>
#include <stdarg.h>
int vsscanf (const char * buf, const char * fmt, va_list ap)
Description
The sscanf() function operates in a similar manner to scanf(), except that instead
of the conversions being taken from stdin, they are taken from the string at
buf.
The
vsscanf() function takes an argument, rather than a list of arguments. See the
description of va_start() for more information on variable argument lists.
See Also
scanf(), fscanf(), sprintf()
Return Value
Returns the value of EOF if an input failure occurs, else returns the number of input
items.