2012-03-18 41 views
-3
#include <iostream> 
using namespace std; 

int main() 
{ 
    // prototypes: 

    float add_and_div(float, float, float); 

    // variables: 

    float x, y, z; 
    float result; 

    cout << "Enter three floats: "; 
    cin >> x >> y >> z; 

// continue the program here 
    add_and_div(x,y,z,); 

当我尝试编译,我得到以下错误信息:语法错误: ')' 1> 1>构建失败。语法错误,我不知道如何纠正C++代码。 (作业项目)

+0

您是否发布了完整的文件? (因为它的main()函数是不完整的,所以不能将其编译为张贴的,因为它的main()函数是不完整的。它有一个开放的大括号,但不是与之匹配的关闭的大括号。) – thb 2012-03-18 22:57:40

+2

'add_and_div(x,y,z,);'< - 有无关的逗号在这里。 – 2012-03-18 22:57:42

+0

'main'函数没有右括号。 – 2012-03-18 23:47:26

回答

3

的语法错误是这样的:

add_and_div(x,y,z,); 

需求是这样的:

add_and_div(x,y,z); 

也就是说,你需要的z后删除逗号。

+0

非常感谢你,EdChum,我是C++的全新人物,这是我的第二个实验室,你今天救了我! – robert 2012-03-18 23:26:30

相关问题