警告:传递 'calcFx' 的参数 2 从指针生成整数而不进行强制转换

warning: passing argument 2 of 'calcFx' makes integer from pointer without a cast

好吧,我找到了我的问题的真正罪魁祸首,对于在此编辑之前在这里的那些人,数字正在扫描。

void computeDataPoints(F_SELECT *fsPtr, int n,  double points[][n])
{
  int ix;  // for indexing points, i.e. columns of 2D array
  double x; // for incrementing the value of x
  double inc;  // incrementation value of x
  inc = (fsPtr->xf - fsPtr->x0)/(n-1);
  x= fsPtr->x0;

 // Setup loop that computes the points and stores in 2D array
  for (ix=0; ix<NUM_POINTS; ix = ix + 1)
   {
      points[X_IX][ix]=x;
      points[FX_IX][ix]=calcFx(x, &fsPtr->fNumber);
      x = x+ inc;
   }
}

我不知道如何解决这个问题并做了一些搜索,如果有人知道如何正确地通过这个过程我会永远爱你

我只是在猜测,因为真的很少继续下去,但我认为情况是这样的:

您在调试器中单步执行代码。当调试器光标位于 scanf 行时,您在对 scanf 的调用处停止。这意味着调用 尚未发生 。您需要再 一步 才能进行 scanf 调用。

另一种可能性是您跳过了 scanf 调用,调试器光标现在位于函数关闭 } 上。根据编译器及其生成的代码,这可能意味着变量 sfPtr 超出范围并且无法由调试器可靠地检查。

解决上述两种情况的方法是在scanf调用和函数结束之间添加另一条语句。例如,一个简单的 printf 调用来打印值:

    ...

    // Select a range of x for plotting
    printf("Select range of x for plotting (x0 and xf):");
    scanf("%lf %lf", &sfPtr->x0, &sfPtr->xf);

    // Print the values just entered
    printf("x0 = %f, xf = %f\n", sfPtr->x0, sfPtr->xf);

    // The function ends here
}

除了打印值外,它还在调试器中提供了一个额外的步骤,用于在调用 scanf.

后检查值

我找到了

points[FX_IX][ix]=calcFx(x, &fsPtr->fNumber);

需要

points[FX_IX][ix]=calcFx(x, fsPtr->fNumber);

感谢所有在我看错地方时试图帮助我的人