#define RAND_MAX 10
#include<stdio.h>
int main()
{
double x;
x=randRange(-1.0,1.0);
printf("x value is %f::",x);
return 0;
}
double randRange(double min, double max)
{
return rand() * (max - min) / RAND_MAX + min;
}
错误::下面的代码片段是正在生成的错误——
$gcc main.c -o demo -lm -pthread -lgmp -lreadline 2>&1
main.c:11:8: error: conflicting types for 'randRange'
double randRange(double min, double max) {
^
main.c:6:5: note: previous implicit declaration of 'randRange' was here
x=randRange(-1.0,1.0);
^
冲突类型中的错误??我检查了返回类型。