猿问

如下所示,在执行 cl.exe 时出错,该怎么解决呢?

#include<stdio.h> #define Height 10 int calculate(int Width, int Long); int main() { int l_long; int l_width; int result; printf("长方形的高度为: %d\n",Height); printf("请输入长度: \n"); scanf("%d",&l_long); printf("请输入宽度: \n"); scanf("%d,&l_width); result=calculate(l_long,l_width); printf("长方形的体积是: \n"); printf("%d\n",result); return 0; } int calculate(int Long, int Width) { int result=Long*Width*Height; return result; } 看书看了半天,我刚学,谁来解释一下,错在那里啊,VC6.0这样说: --------------------Configuration: Hello - Win32 Debug-------------------- Compiling... calculate.c C:\Documents and Settings\Administrator\桌面\calculate.c(13) : error C2001: newline in constant C:\Documents and Settings\Administrator\桌面\calculate.c(14) : error C2146: syntax error : missing ')' before identifier 'result' 执行 cl.exe 时出错. calculate.obj - 1 error(s), 0 warning(s) 还是错了啊。

开心每一天1111
浏览 234回答 2
2回答

莫回无

#include<stdio.h>#defineHeight10intcalculate(intWidth,intLong);intmain(){intl_long;intl_width;intresult;printf("长方形的高度为:%d\n",Height);printf("请输入长度:\n");scanf("%d",&l_long);printf("请输入宽度:\n");scanf("%d,&l_width);//忘记加双引号了scanf("%d",&l_width);result=calculate(l_long,l_width);printf("长方形的体积是:\n");printf("%d\n",result);return0;}intcalculate(intLong,intWidth){intresult=Long*Width*Height;//你这个地方改成先定义再计算,分开写,intresult;result=Long*Width*Height;returnresult;}//其它的你再你电脑上检查有没有大小写错误就行了

尚方宝剑之说

#include<stdio.h>#defineHeight10intcalculate(intWidth,intLong);intmain(){intl_long;intl_width;intresult;printf("长方形的高度为:%d\n",Height);printf("请输入长度:\n");scanf("%d",&l_long);printf("请输入宽度:\n");scanf("%d",&l_width);//result=calculate(l_long,l_width);printf("长方形的体积是:\n");printf("%d\n",result);return0;}intcalculate(intLong,intWidth)//{intresult=Long*Width*Height;returnresult;}
随时随地看视频慕课网APP
我要回答