救命啊,我迷糊死了
本帖最后由 三千芳华 于 2018-6-3 14:42 编辑#include <stdio.h>
float main()
{
float a,b,z;
float shu(float x,float y);
scanf("%f %f",&a,&b);
z=shu(a,b);
printf("%f",z);
}
float shu(float x,float y)
{
float t,z;
if(y>z)
{
t=y;
x=t;
y=x;
}
z=x-y;
return z;
}
将float main的float改为int就不会报错,如果用float这样为啥会报错,如果硬要用float mian要怎么改? 求大佬解决一下啊,真心不懂啊 启动代码规定了 main 函数的格式为 int main
硬要用float也可以,要自定义启动代码
下面的程序自定义了启动代码为 begin 函数,由 begin 函数(启动代码)调用 float main,float main 返回后由启动代码终止程序
#include <stdio.h>
#include <stdlib.h>
float main(void);
void begin(void)
{
printf("begin call main\n");
float main_ret = main();
printf("end call main\n");
printf("float main return: %f\n", main_ret);
exit(0); // return 0
}
float main(void)
{
printf("float main\n");
return 12.3; // test
}
人造人 发表于 2018-6-3 16:35
启动代码规定了 main 函数的格式为 int main
硬要用float也可以,要自定义启动代码
谢谢大佬,终于明白原因了
页:
[1]