C++中系统报错newline in constant是什么意思?

如题所述

一般从网页上直接拷代码下来编译时,许多全角符号没有转成半角符号,编译器不能识别,所以要手工把全角符号改成半角,如:“”等。

#include<stdio.h>
int main()
{
float a,b,c,d;
float temp;
scanf("%f %f %f %f, &a, &b, &c, &d);
temp=a
if(temp<b)
temp=b;
if(temp<c)
temp=c;
if(temp<d)
temp=d;
printf("\nmax=%f",temp);
return 0;

}

error C2146: syntax error : missing ´)´ before identifier temp
error C2001: newline in constant

修改后为:
#include<stdio.h>
int main()
{
float a,b,c,d;
float temp;
scanf("%f %f %f %f", &a, &b, &c, &d);//这里有修改,少了一个"
temp=a;//这里少了一个分号
if(temp<b)
temp=b;
if(temp<c)
temp=c;
if(temp<d)
temp=d;
printf("\nmax=%f",temp);
return 0;
}
温馨提示:答案为网友推荐,仅供参考
第1个回答  2006-10-08
一般从网页上直接拷代码下来编译时,许多全角符号没有转成半角符号,编译器不能识别,所以要手工把全角符号改成半角,如:“”等。本回答被提问者采纳
第2个回答  2006-10-08
在程序的末尾点个回车,重新开一行试试。
第3个回答  2020-04-21
一般从网页上直接拷代码下来编译时,许多全角符号没有转成半角符号,编译器不能识别,所以要手工把全角符号改成半角,如:“”等。
#include<stdio.h>
int
main()
{
float
a,b,c,d;
float
temp;
scanf("%f
%f
%f
%f,
&a,
&b,
&c,
&d);
temp=a
if(temp<b)
temp=b;
if(temp<c)
temp=c;
if(temp<d)
temp=d;
printf("\nmax=%f",temp);
return
0;
}
error
C2146:
syntax
error
:
missing
´)´
before
identifier
temp
error
C2001:
newline
in
constant
修改后为:
#include<stdio.h>
int
main()
{
float
a,b,c,d;
float
temp;
scanf("%f
%f
%f
%f",
&a,
&b,
&c,
&d);//这里有修改,少了一个"
temp=a;//这里少了一个分号
if(temp<b)
temp=b;
if(temp<c)
temp=c;
if(temp<d)
temp=d;
printf("\nmax=%f",temp);
return
0;
}
第4个回答  2019-06-17
一般从网页上直接拷代码下来编译时,许多全角符号没有转成半角符号,编译器不能识别,所以要手工把全角符号改成半角,如:“”等。
#include<stdio.h>
int
main()
{
float
a,b,c,d;
float
temp;
scanf("%f
%f
%f
%f,
&a,
&b,
&c,
&d);
temp=a
if(temp<b)
temp=b;
if(temp<c)
temp=c;
if(temp<d)
temp=d;
printf("\nmax=%f",temp);
return
0;
}
error
C2146:
syntax
error
:
missing
´)´
before
identifier
temp
error
C2001:
newline
in
constant
修改后为:
#include<stdio.h>
int
main()
{
float
a,b,c,d;
float
temp;
scanf("%f
%f
%f
%f",
&a,
&b,
&c,
&d);//这里有修改,少了一个"
temp=a;//这里少了一个分号
if(temp<b)
temp=b;
if(temp<c)
temp=c;
if(temp<d)
temp=d;
printf("\nmax=%f",temp);
return
0;
}