看了你和别人的交流直接上个代码吧folat fun(float x);float a,b;main(){scanf("输入x",&a);b=fun(a);printf("x=%f",b);}float fun(float x){float ret;FILE* fp;if(x=-1)ret = x*2;fp = fopen("result.txt", "w");fprintf(fp, "x=%f", ret);return ret;}这样就是你要求的了主函数不变在fun中返回同时输入到文件然后主函数正常输出
温馨提示:答案为网友推荐,仅供参考