gpt4 book ai didi

c - 警告 : passing argument 2 of 'calcFx' makes integer from pointer without a cast

转载 作者:行者123 更新时间:2023-11-30 16:39:07 25 4
gpt4 key购买 nike

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

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 后检查值。

关于c - 警告 : passing argument 2 of 'calcFx' makes integer from pointer without a cast,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47194602/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com