drand48_r函数用法详解
drand48_r函数简介
- 头文件包含
#include <stdlib.h>
- 函数定义
int drand48_r(struct drand48_data * buffer , double * result );
int erand48_r(unsigned short xsubi [3] ,
struct drand48_data *buffer , double * result );
int lrand48_r(struct drand48_data * buffer , long * result );
int nrand48_r(unsigned short xsubi[3] ,
struct drand48_data *buffer , long * result );
int mrand48_r(struct drand48_data * buffer ,long * result );
int jrand48_r(unsigned short xsubi[3] ,
struct drand48_data * buffer , long * result );
int srand48_r(long int seedval , struct drand48_data * buffer );
int seed48_r(unsigned short seed16v[3] ,
struct drand48_data * buffer );
int lcong48_r(unsigned short param[7] ,
struct drand48_data * buffer );
drand48_r函数常见使用错误
- 编译错误
warning: implicit declaration of function ‘drand48_r’ [-Wimplicit-function-declaration]
解决办法:包含头文件
#include <stdlib.h>
drand48_r函数详细描述
这些函数是drand48 (3)中描述的函数的可重入类似物,它们使用提供的数据buffer 而不是修改全局随机生成器状态
在第一次使用之前,必须初始化这个结构,例如,用零填充它,或者调用函数srand48_r ()、seed48_r ()或lcong48_r ()之一
drand48_r函数返回值
返回值为0。
评论区