C语言的问题,急求高手~~解决的话高分相赠

来源:百度知道 编辑:UC知道 时间:2024/05/14 11:16:25
先前我输入的程序是错误的,即:
#include <stdio.h>
#include <math.h>
main()
{int a;
float b;
double d;
scanf("%d,%f,a,b);
c=a+b;
d=sqrt(a-b);
printf("a=%d,b=%f\n",a,b);
printf("a+b=%d\n",c);
printf("d=%f\n",d);
}

在自己的本上报错如下:
--------------------Configuration: ex11 - Win32 Debug--------------------
Compiling...
Error spawning cl.exe

ex11.exe - 1 error(s), 0 warning(s)

可是,我将我的VC++程序复制到学校机房,运行报错为
--------------------Configuration: 6 - Win32 Debug--------------------
Compiling...
6.c
c:\program files\microsoft visual studio\myprojects\6\6.c(7) : error C2001: newline in constant
c:\program files\microsoft visual studio\myprojects\6\6.c(8) : error C2146: syntax error : missing ')' before identifier 'c'
c:\program files\microsoft vi

看样子,你的电脑中的VC设置可能有点问题,请参考下文:

安装VC 6.0后点击“Compile”或者“Build”出现
“Compiling... ,Error spawning cl.exe”错误提示给,实际上这个问题很多情况下是由于路径设置的问题引起的,
“CL.exe”是VC使用真正的编译器(编译程序),其路径在“VC根目录\VC98\Bin”下面,
你可以到相应的路径下找到这个应用程序。

因此问题可以按照以下方法解决:打开vc界面 点击VC“TOOLS(工具)”—>“Option(选择)”
—>“Directories(目录)”重新设置“Excutable Fils、Include Files、
Library Files、Source Files”的路径。很多情况可能就一个盘符的不同
(例如你的VC装在C,但是这些路径全部在D),改过来就OK了。

有些<math.h>函数库定义的sqrt原型是
extern float sqrt(int x)
有些是
extern float sqrt(float x)
你只要把你们学校的include/math.h copy到你家去就可以了
C的版本不一样~,标准也就不同,函数库自然也不一定全部一样了

因此问题可以按照以下方法解决:打开vc界面 点击VC“TOOLS(工具)”—>“Option(选择)”
—>“Directories(目录)”重新设置“Excutable Fils、Include Files、
Library Files、Source Files”的路径。很多情况可能就一个盘符的不同
(例如你的VC装在C,但是这些路径全部在D),改过来就OK了

#include <stdio.h>
#include <math.h>
main()
{int a,c;
float b;
double d;
scanf("%d,%f"