Where is the random function in C?

Asked 1 years ago, Updated 1 years ago, 61 views

Where are the random functions provided by the standard library? Or should I get another package?

c random

2022-09-21 19:35

1 Answers

<stdlib.h> has a land() function. Return the integer from 0 to RAND_MAX at random.

I need to be careful when I use it rand() Actually, it's not completely random, but it's implemented in a way that returns the integers that are already randomly listed You need to set seed to get a different number each time you run it.

Required for #include <time.h> //seed
#include <stdlib.h>

srand(time(NULL); //seedWrite
int r = rand();


2022-09-21 19:35

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.