I need help resolving this error message in my code. This code is supposed to run two functions, readCards() which updates a list with card numbers, and numOfTargetCardInHand() which is supposed to tell me how many times a targeted number is found in a list. I am still new to coding in general so please try to explain it as simply as possible.
Here is my code:
#include <iostream>
using namespace std;
const int HAND_SIZE = 5;
void readCards(int list[], int& size);
int numOfTargetCardInHand(const int array[], int size, int targetCard);
int main()
{
int hand[HAND_SIZE];
int size;
int specificCard;
readCards(hand, size);
specificCard = numOfTargetCardInHand(hand, size, 4);
cout << "the size of this array is: " << size << endl
<< "the amount of times the specified card was found:" << specificCard;
}
/*__________________________________________________________________________________________*/
//This function receives card numbers and puts them in an array
void readCards(int list[], int& size)
{
int number, count;
count = 0;
cout << "Enter 5 numeric cards, no face cards.Use 2 - 9." << endl;
cout << "Card " << count + 1 << ": ";
cin >> number;
while (count < HAND_SIZE) {
list[count] = number;
count++;
if (count < HAND_SIZE) {
cout << "Card " << count + 1 << ": ";
cin >> number;
}
}
size = count;
}
/*__________________________________________________________________________________________*/
//this function loops through the array and counts the amount of times that a card inside the array equals the target card and returns that value
int numOfTargetCardInHand(int array[], int size, int targetCard)
{
int targetCardCounter = 0;
for (int i = 0; i < size; i++) {
if (array[i] == targetCard)
targetCardCounter += 1;
}
return targetCardCounter;
}
These two error messages appear:
Error LNK2019 unresolved external symbol "int __cdecl numOfTargetCardInHand(int const * const,int,int)" (?numOfTargetCardInHand@@YAHQBHHH@Z) referenced in function _main Lab4 C:\Users\bobb9\source\repos\Lab4\Lab4\Crap.obj 1
Error LNK1120 1 unresolved externals Lab4 C:\Users\bobb9\source\repos\Lab4\Debug\Lab4.exe 1
Here are my questions
Why is another file (
Lab4.exe) in my source files path for the project causing this error? I did transfer functions from that file into the current one, but I commented that file out fully. Should I move the file elsewhere and still take functions from it?How do I read and understand these types of errors. I am in college and I am learning this and really struggling understanding what these messages the computer is telling me.
Also how do you find motivation to push through and ultimately learn, and where do you guys learn all of this information, I want to become really knowledgeable and become a capable programmer.