小编use*_*347的帖子

冲突类型中的C错误

#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;
}
Run Code Online (Sandbox Code Playgroud)

错误::下面的代码段是生成的错误 -

$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);
^
Run Code Online (Sandbox Code Playgroud)

冲突类型出错?我检查了返回类型.

c compiler-errors

1
推荐指数
1
解决办法
803
查看次数

C-File处理中的编译错误

#include<stdio.h>
#include<conio.h>
FILE *fp;
int main()
{
  int val;
  char line[80];
  fp=fopen("\Users\P\Desktop\Java\a.txt","rt");
  while( fgets(line,80,fp)!=NULL )
   {
     sscanf(line,"%d",&val);
     printf("val is:: %d",val);
   }
   fclose(fp);
   return 0;
}
Run Code Online (Sandbox Code Playgroud)

为什么行fp = fopen("\ Users\P\Desktop\Java\a.txt","rt")中存在编译错误?

c error-handling compiler-errors

-1
推荐指数
1
解决办法
220
查看次数

标签 统计

c ×2

compiler-errors ×2

error-handling ×1