C语言--[Error] ld returned 1 exit status--解决方法。

报错 [Error] ld returned 1 exit status

可能原因:
1.是否已经有黑框在运行了?
2.是否main出了问题?

解决方法:
1.若后台已经有黑框再运行,则结束黑框;
2.若无黑眶,可能是main 函数出了问题,可查看是否把函数的定义写到了main函数中。

#include<stdio.h>

	float count(int a, int b, int c, float x);
	int main(void)
	{
		int a = 0, b=0, c = 0;
		float x = 0, y =0;
		
		printf("请依次输入三元一次方程的系数a、b、c x;系数和x之间用空格键隔开:\n");
		scanf("%d %d %d %f", &a, &b, &c, &x);
		printf("%f", count(a, b, c, x));
		
		/**下列函数定义写到了main函数内部,
		报错:[Error] ld returned 1 exit status*/
		float count(int a, int b, int c, float x)
	    {
		float y = 0;
		y = a*x*x*x+b*x*x+c;
		return y;
     	}
		
		return 0;
	} 

报错:
在这里插入图片描述
将函数定义写道main函数外面即可。

猜你喜欢

转载自blog.csdn.net/weixin_43641971/article/details/88284773