Ich habe nach der Antwort für ungefähr 4 Stunden gesucht und es ist schmerzhaft, bis jetzt habe ich mehrere Korrekturen getroffen, wie man den tatsächlichen Fehler, ich loswerde hab fast 2 ganze seiten des vorherplakats gelesen LNK2019 & LNK1120 fehler und ich verstehe immer noch nicht, wie die fixen bisher funktionieren, ich habe keine externen libraries eingebaut. Ich habe versucht zu finden, wonach ich suche, aber um ehrlich zu sein, verstehe ich nicht, wonach ich suche, da ich keine externe API oder etwas ähnliches implementiert habe, nun, ich glaube nicht ist mein Freundescode, also weiß ich nicht, was er noch implementiert hat, bitte helft auch, hier ist auch der Quellcode.Fehler LNK2019 und LNK1120, ungelöstes externes und unaufgelöstes Symbol
Fehler LNK2019 nicht aufgelöstes externes Symbol "Leere __cdecl displaySpace (int, Klasse> std :: basic_string, Klasse std :: Allocator>, Bool, char)" (? DisplaySpace @@ YAXHV? $ Basic_string @ DU? char_traits $ @ D @ std @@ V? $ allocator @ D @ 2 @@ std @@ _ ND @ in Funktion _main
verwiesen Z)
(er sagte auch, es auf Linie 1) war
LNK1120, 1 nicht aufgelöste externe (Es wurde auch gesagt, dass es in Zeile 1 war)
#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];
}
}
Was ist die kleinste Teilmenge dieses Codes, die dieses Problem zeigt? Und was ist die größte Teilmenge dieses Codes, die funktioniert? –