LNK2019和LNK1120错误,未解析的外部和未解析的符号
LNK2019 and LNK1120 error, unresolved external and unresolved symbol
我一直在寻找这个问题的答案大约 4 个小时,它很痛苦,到目前为止,我已经遇到了有关如何摆脱实际错误的多个修复程序,我已经阅读了近 2 整页的先前海报 LNK2019 和 LNK1120 错误,到目前为止我仍然不明白修复是如何工作的,我没有包含任何外部库。我试图找到我正在寻找的东西,但老实说我不明白我在寻找什么,因为我还没有实现外部 API 或类似的东西,好吧,我不相信,这是我的朋友代码,所以我不知道他还实现了什么,请帮忙,这也是源代码。
错误 LNK2019 未解析的外部符号"void __cdecl displaySpace(int,class> std::basic_string, class std::allocator>,bool,char(" (?displaySpace@@YAXHV?$basic_string@DU? $char_traits@D@std@@V?$allocator@D@2@@std@@_ND@Z( 在函数_main中引用
(还说在1号线上(
LNK1120,1个未解析的外部(它也说它在1行(
#include <string>
#include <iostream>
#include <array>
using namespace std;
int main()
{
string userString;
const int maxWordLength = 32;
char userWord[maxWordLength];
char remainingLetters[26] = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' };
int health = 0;
int wordLength = 0;
int letterFind = 0;
int index = 0;
bool gameOver = false;
bool inputValid = false;
bool inputValid2 = false;
char guessChar = ' ';
void displaySpace(int wordLength, string userWord, bool correctGuess, char guessChar);
while (!inputValid)
{
//ask for pharse/word
cout << "Player 1, pick a word or pharse less than (no caps) " << maxWordLength << " characters: " << endl;
getline(cin, userString);
//cout << userString << endl;
wordLength = userString.length();
// << wordLength << endl;
if (wordLength <= maxWordLength)
{
//skips down so player 2 does not cheat
for (int i = 0; i < 100; i++)
{
cout << " " << endl;
}
for (int i = 0; i < wordLength; i++)
{
userWord[i] = userString[i];
}
displaySpace(wordLength, userWord, false, guessChar);
inputValid = true;
}
else
{
continue;
}
while (!gameOver)
{
cout << " " << endl;
cout << "Player 2, guess a letter in the phrase/word: " << endl;
cin >> guessChar;
while (!inputValid2)
{
if (!isalpha(guessChar))
{
continue;
}
else
{
cin >> guessChar;
for (int i = 0; i < wordLength; i++)
{
if (userWord[i] == guessChar)
{
for (int k = 0; k < 26; k++)
{
if (remainingLetters[k] == guessChar)
{
for (index = k; index < 26; index++)
{
int temp = remainingLetters[index];
remainingLetters[index] = remainingLetters[index + 1];
remainingLetters[index + 1] = temp;
}
for (int index = 0; index < k; index++)
{
cout << remainingLetters[index] << " ";
}
for (int i = 0; i < 26; i++)
{
cout << remainingLetters[i] << endl;
}
}
else
{
continue;
}
}
}
else
{
}
}
inputValid = true;
}
}
}
}
return 0;
}
void displaySpace(int wordLength, string userWord, bool correctGuess, char
guessChar, char remainingLetters[26])
{
string displayspace[32]= {" "," ", " ", " ", " ", " ", " ", " ", " ", " ", "
", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", "
", " ", " ", " ", " ", " ", " ", };
string space = " ";
string dash = " _ ";
string guessString(1, guessChar);
cout << guessString << endl;
for (int i = 0; i < 32; i++) {
displayspace[i] = " ";
}
for (int i = 0; i < wordLength; i++)
{
for (int k = 0; i < 26; i++) {
if (remainingLetters[k] == userWord[i])
{
displayspace[i] = dash;
cout << dash;
}
}
if (correctGuess == true)
{
displayspace[i] = guessString;
cout << guessString;
}
else
{
displayspace[i] = space;
cout << space;
}
}
for (int i = 0; i < wordLength; i++)
{
cout << displayspace[i];
}
}
函数原型(和调用站点(不匹配:
void displaySpace(int wordLength, string userWord, bool correctGuess, char guessChar);
和实际函数定义:
void displaySpace(int wordLength, string userWord, bool correctGuess, char guessChar, char remainingLetters[26])
这就是编译器找不到匹配函数的原因。
相关文章:
- C++:Application.cpp中抛出了未解析的外部符号(解决方案在问题的末尾,供未来的读者参考)
- 未解析的外部符号_MsiLocateComponentW@12.
- 在C++中使用 gRPC 时未解析的外部符号
- LibPrivoxy: 未解析的外部符号 __declspec(dllimport) int __stdcall Sta
- 尝试从 XamlApplication 编译 C++/WinRT 空白应用程序时,我收到未解析的外部符号 winrt_make_*
- 我收到错误LNK2001:未解析的外部符号(C++代码)
- 可视抽象类 c++(错误 LNK 2001:未解析的外部符号)
- 如何摆脱C++中未解析的外部符号"private: static char"错误?
- 当 lib 已添加到其他依赖项时,如何在 VS 中调试未解析的外部符号错误
- 仅在少数方法(静态或共享库)中解析的外部符号
- 未解析的外部符号"__declspec(dllimport)与 Spdlog c++ 库
- 函数 _main (OPENGL C++) 中引用的未解析的外部符号 ________
- 错误LNK2019未解析的外部符号"public: __thiscall SLinkList<char>::SLinkList<char>(void)"
- 使用静态 constexpr 成员的未解析外部符号
- 引入参数化构造函数后显示 LNK 2019 未解析外部符号的代码错误
- Dlib LNK2001未解析的外部符号USER_ERROR__consistent_build_configurati
- 矛盾的未解决的外部符号+未使用的库与VS2017和FFMPEG 4
- 链接器错误:切换到unicode生成给出:未解析的外部符号WinMain
- 类模板上一个特定函数的未解析外部符号
- LNK2001:未解析的外部符号public:static类std::vector