I wrote code like this:
#include <iostream>
#define _CRT_RAND_S // may this line cause problem
#include <stdlib.h>
int main(void)
{
unsigned int r;
rand_s(&r);
// ...
return 0;
}
and compiler said, cannot find rand_s(). Then I switched line 1 and 2, it works.
#define _CRT_RAND_S
#include <iostream>
#include <stdlib.h>
// ...
Question is,
- Why do I have to define
_CRT_RAND_S
at the top of code? - Does
<iostream>
depends on_CRT_RAND_S
? It seems not but...
I tried this in Windows x64, Visual Studio 2022. Thanks.
Aucun commentaire:
Enregistrer un commentaire