我知道它是重复的...我不理解其他任何线程。从字面上看才刚刚开始学习编程。目前正在尝试将C ++作为我的第一语言。遇到这个错误,我在Google上进行了搜索,但我真的不知道他们在说什么。我看着我的两个“ int main”东西,它们是完全一样的。没有错误。我猜格式错误。这是代码。我目前正在玩std :: count和变量,以及std:cin
#include <iostream>
int main()
{
std::cout << "Hello, how are you doing? I suppose you are only here to read this. Oh well.";
return 0;
}
int main()
{
std::cout << "Please feed me a number: " << "It can be any number."; // Asking human to enter a number.
int x{ }; // get number from keyboard and store it in value x
std::cin >> x; // recieved number and is now entering console
std::cout << "Thank you for feeding me " << x << '\n';
return 0;
}
答案 0 :(得分:-1)
一个C ++程序仅需要一个main()
函数。后者在程序启动时称为。您的代码应如下所示:
#include <iostream>
int main()
{
std::cout << "Hello, how are you doing? I suppose you are only here to read this. Oh well." << std::endl;
std::cout << "Please feed me a number: " << " It can be any number." << std::endl; // Asking human to enter a number.
int x{ }; // get number from keyboard and store it in value x
std::cin >> x; // recieved number and is now entering console
std::cout << "Thank you for feeding me " << x << std::endl;
return 0;
}
这里有link,以详细了解main()
函数。