jeudi 16 février 2017

rand/srand functions in C

I'm trying to understand how do 'rand' and 'srand' functions work:

#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>

int main(void)
{
unsigned int seed;
printf("please type in new seed:\n");
scanf("%i", &seed);
void srand(unsigned int seed);
int rand(void);
printf("%i\n", rand);   
return 0;
}

But my compiler says: **"format ‘%i’ expects argument of type ‘int’, but argument 2 has type ‘int ()(void)’ [-Wformat=] printf("%i\n", rand);"*

Where is the mistake?




Aucun commentaire:

Enregistrer un commentaire