LNK2019和LNK1120错误,未解析的外部和未解析的符号

LNK2019 and LNK1120 error, unresolved external and unresolved symbol

本文关键字:外部 符号 LNK1120 LNK2019 错误      更新时间:2023-10-16

我一直在寻找这个问题的答案大约 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])

这就是编译器找不到匹配函数的原因。