c++ - 未定义对 WinMain 的引用,[错误] ID 返回 1 退出状态

标签 c++

我在这里搞砸了什么?代码中不能有硬编码值,这就是为什么我的所有提示都是常量。我们还必须调用用户定义的函数来验证输入。

我在编译时遇到以下错误——未定义对 WinMain 的引用,[错误] Id 返回了 1 个退出状态我正在使用 Dev C++ 作为 IDE

#include <iostream> //for I/O
#include <iomanip> //for formatting output

using namespace std;


const string PROGRAM_DESCRIPTION = "Program will calculate the amount "
"accumulated every month you save, \nuntil you reach your goal. ";
const string ENTER_DOLLAR_AMOUNT_MONTHLY = "Enter the dollar amount to be "
"saved each month: ";




int main()
{
    double dollarSavedPerMonth; 


    //displays program description
    cout << PROGRAM_DESCRIPTION << endl << endl;

    //Prompts user to enter dollar amount to be saved monthly, will validate
    //input by calling VerifyDollar
    dollarSavedPerMonth = VerifyDollar(ENTER_DOLLAR_AMOUNT_MONTHLY);
    cout << endl;



    return 0;
}




double VerifyDollar (string Prompt)
{
    const string INVALID_DOLLAR_AMOUNT = "Invalid amount, re-enter monthly "
    "savings amount.";
    double dollarSaved;

    cout << Prompt;
    cin >> dollarSaved;

    while (dollarSaved < 5 || dollarSaved > 5000)
    {
          cout << INVALID_DOLLAR_AMOUNT;
          cout << endl;
          cout << Prompt;
          cin >> dollarSaved;
    }
    return dollarSaved;
}

最佳答案

您确实在该代码中的任何地方都缺少 WinMain() 函数。

如果没记错的话,WinMain() 是 Win32 GUI 应用程序的入口点。我假设您的 IDE 要求您提供某种“项目类型”,而您要求的是 Windows 应用程序而不是控制台应用程序。

在这种假设下,您项目中的某些内容被配置为调用您未定义的 WinMain(),因此出现链接器错误。

关于c++ - 未定义对 WinMain 的引用,[错误] ID 返回 1 退出状态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21652922/

相关文章:

c++ - 将数组与整数打印为十六进制

c++ - 对 nvcpl.dll 的 NvCplGetThermalSettings 调用返回 false (C++)

自定义类构造函数中的 C++ 指针赋值

c++ - 比较列表并给出列表 b 中不在列表 a 中的内容

c++ - Qt -"\n"不起作用,但 std::endl 可以吗?

c++ - 如何在包含类的 vector 中使用 std::less

c++ - 从 C++ 中的外部程序捕获 stderr 和 stdout

c++ - 强制QWebView在单独的线程中下载网页内容?

c++ - 动态上下文相关运算符的设计模式(例如模运算)?

c++ - 当我尝试在 Ubuntu bash 中运行我的程序时,出现此错误 : "/usr/lib/x86_64-linux-gnu/libstdc++.so.6: version ` GLIBCXX_3. 4.2 1' not found "