链接器问题再次出现
Linker Trouble once more
嗨,我一直在尝试 2 个小时试图找到这些错误的原因:
错误1 错误 LNK2019:函数___tmainCRTStartup中引用未解析的外部符号_main
错误 2 错误 LNK1120:1 个未解析的外部
我检查了子系统,它也在控制台上设置。我不知道怎么了,我也是新手C++所以慢慢解释(请)
#include <iostream>
#include <conio.h>
#include <string>
using namespace std;
int Range1, Range2, Guess, Midpoint, NumOfGuess;
string Selection;
bool GameQuit = false;
void MidpointReset()
{
Midpoint = rand() % 31 + 0;
Range1 = rand() % Midpoint + 0;
Range2 = rand() % 31 + Midpoint;
}
void RangeReset()
{
Range1 = rand() % Midpoint + Range1;
Range2 = rand() % Range2 + Midpoint;
}
int Main()
{
MidpointReset();
while (GameQuit == false)
{
cout << "1. Show me the range" << endl
<< "2. I want to guess the number" << endl
<< "3. Quit" << endl
<< "4. Reset MidPoint"
<< "Enter your selection :" << endl;
cin >> Selection;
if (Selection == string("1"))
{
cout << "Between " << Range1 << " and " << Range2 << endl;
RangeReset();
}
else if (Selection == string("2"))
{
cout << "Enter your guess:" << endl;
cin >> Guess;
NumOfGuess += 1;
if (Guess == Midpoint)
{
cout << endl << "Right! It took you " << NumOfGuess << " trials!";
GameQuit = true;
break;
}
}
else if (Selection == string("3"))
{
MidpointReset();
}
else if (Selection == string("4"))
{
cout << "Thanks for playing!";
GameQuit = true;
break;
}
else
{
cout << "Sorry " << Selection << "Is a invalid selection";
}
}
cout << "Please press any key to exit...";
_getch();
return 0;
}
小
写在main()
中很重要
Main()
切换到main()
以找到入口点。
作为旁注:
cout << "1. Show me the range" << endl
<< "2. I want to guess the number" << endl
<< "3. Quit" << endl
<< "4. Reset MidPoint"
<< "Enter your selection :" << endl;
....
else if (Selection == string("3"))
{
MidpointReset();
}
else if (Selection == string("4"))
{
cout << "Thanks for playing!";
GameQuit = true;
break;
}
3 和 4 在帮助选择中交换:4 退出,3 重置中点。
相关文章:
- 静态数据成员的问题-修复链接错误会导致编译器错误
- 基于boost的程序的静态链接——zlib问题
- 使用jsoncpp库时出现链接问题
- Cmake 链接问题:未定义对 Button::mousePressEvent(QGraphicsSceneMouseE
- sqlite3 和生成文件中的链接出现问题
- 如何将GTest与CMake一起使用?遵循谷歌指南时的链接问题
- 未解决的外部链接问题
- 使用转换器提升 Python 问题 - 静态链接
- 'make check' GLIBC 运行时的链接问题
- 在树莓派上用libtorch构建程序时的链接问题
- QtCreator with C 库中的链接器问题
- 野牛弹性链接问题
- 与 AWS 开发工具包的链接问题
- 使用 NVIDIA GPU 在 Cygwin 中链接 OpenCL 库时遇到问题
- 为什么当我从语句检查中删除"+ mod"时,以下程序给出错误的答案。问题链接:https://www.codechef.com/problems/FFC219B
- PCL 和 CMake 的问题:链接时未定义统计异常值删除
- VC++使用gumbo查询时出现问题(链接错误)
- 使用CMake问题链接Boost(Ubuntu 14.04)
- MySQL连接器问题-链接等等
- MinGW 与 MSVC 的 dll 库问题链接(未定义的引用)