如何更正此程序执行的错误?

时间:2009-03-03 15:54:09

标签: c++

我已经尝试了所有东西,这是我的第一个C ++程序,但它没有正确出现。我收到两条错误消息。 error7:1 warning: character constan too long for its type.7:error: expe

//My first C++ program
#include <iostream>
int main():
{
    "-std::cout << "I will get it" << -std::cout::end1";
    "-std::cout << "I hope so" << -std::end1;
    return(0);
}

4 个答案:

答案 0 :(得分:11)

您的代码应该像这样修复:

#include <iostream>
int main()
{
    std::cout << "I will get it" << std::endl;
    std::cout << "I hope so" << std::endl;
    return 0;
}

答案 1 :(得分:3)

您的报价完全错误,:后有一个虚假的“main()”字符。您还需要一些额外的'-'个字符。最后,在一个案例中,您指定了std::end1您想要std::endl的位置,而在另一个案例中,您指定了std::cout::end1'1',您想要'l'} { {1}}。感谢Scottie T的那次捕获。

我相信你想要:

std::endl

答案 2 :(得分:0)

看起来您正在为示例添加标点符号。在编程语言中,您必须准确输入所给的内容。

'int main()'

不同
int main()

答案 3 :(得分:0)

此外,您可以声明

using namespace std;

之前

int main()

,您不需要每次都输入std::