Im getting these two errors, here is the whole code besides the edits and i know the edits works so their not important here.

Error 6 error LNK2019: unresolved external symbol "int __cdecl loadArray(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const (* const)[2])" (?loadArray@@YAHQAY01$$CBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function _main Q6_A1_CODE.obj
Error 7 fatal error LNK1120: 1 unresolved externals C:\Users\HomePC\Desktop\Q6_assignment1\Debug\Q6_assignment1.exe

can someone tell me what im getting the errors for?

//header files
#include<iostream>
#include<string>
#include<iomanip>
#include<fstream>
#include<algorithm>
#include<cstdlib>
#include<stdlib.h>

//declare namespace
using namespace std;

//declarations
void newMember(string[][2],int);
void existingMember(string[][2]);
void editData(int&,string,int,int);
void editData(string&,string,int,int);
void editData(long&,string,int,int);
void stateArray(string& state);	
void countryArray(string& country);	
int loadArray(const string[][2]);
int arraySearch(const string[][2],const string&,const string&);
//*********************************************************************
//---------------------------------------------------------------------
//*********************************************************************
int main()
{
	//clear screen
	system("cls");
	//declare variable for switch case
	char choice = ' ';
	//declare array
	string secArray[10][2];

		//open sec.dat for append :::here:::
		  ofstream inFile;
		  inFile.open("sec.data",ios::app);
		  inFile.close();
		//close (creating an EOF) :::here:::

	int index = loadArray(secArray);
	// loop for forcing a,b or c choices
	do
	{
		//set up menu screen
		cout<<'\n';
		cout<<"================================================================================";
		cout<<"                                  Join A Clan"<<endl;		cout<<"================================================================================";
		cout<<'\n';
		cout<<'\n';
		cout<<"  a - New Member "<<endl;
		cout<<'\n';
		cout<<"  b - Existing Member "<<endl;
		cout<<'\n';
		cout<<"  c - Exit "<<endl;
		cout<<'\n';
		cout<<'\n';
		cout<<"  Please enter your choice ---> ";
		cin>>choice;
		
			//set up switch / case
			switch(choice)
			{
			case 'a':
				system("cls");
				//call function newMember()
				newMember(secArray,index);
				break;
			case 'b':
				system("cls");
				//call function existingMember()
				existingMember(secArray);
				break;
			case 'c':
				system("cls");
				// exit the program
				break;
			default:
		//incorrect choice, will loop back to force a correct answer
				system("cls");
				cout<<"Not a valid choice "<<endl;
				system("pause");
			}
	}
	while(choice != 'a' && choice != 'b' && choice != 'c');
//return 0(zero)
return 0;
}
//*********************************************************************
//---------------------------------------------------------------------
//*********************************************************************
void newMember(string secArray[][2],int index)
{
//cout<<"new member works! "<<endl;
//declare variables
string teamTag = "";
string callSign = "";
string name = "";
string address = "";
string city = "";
string state = "";
int zip = 0;
string country = "";
long cdCode = 0.0;
int password = 0;
char n_pArray_Found = 'n';


		//header
		system("cls");
		cout<<'\n';
		cout<<"================================================================================";
		cout<<"                                  New Member"<<endl;
		cout<<"================================================================================";
		cout<<'\n';
		cout<<'\n';
		cout<<"  Enter registration info:"<<endl;
		cout<<'\n';
		cout<<'\n';
		cin.ignore(1);

			do
			{
				//input	
			editData(callSign," Call Sign(screenname): ",3,20);
				cout<<'\n';
			        editData(name," Name: ",2,25);
				cout<<'\n';	
				//search secArray here for name and password and 
				//assign the value of the return to result
			int result = arraySearch(secArray,name,callSign);	
				//end search

					if(result == -1)
					{
							//add to array :::here:::

						index++;

							//add to sec.dat :::here:::
					}
					else
					{
						n_pArray_Found = 'y';
					}
			}
			while(n_pArray_Found == 'n');

			editData(password," Password: ",100000,999999);
			cout<<'\n';
			editData(teamTag," Team Tag: ",15,15);
			cout<<'\n';
			cin.ignore(1);
			editData(address," Address: ",3,25);
			cout<<'\n';
			editData(city," City: ",3,15);
			cout<<'\n';
			//call array function (state)
			stateArray(state);
			cout<<'\n';
			editData(zip," Zip: ",1000,99000);
			cout<<'\n';
			cin.ignore(1);
			//call array function (country)
			countryArray(country);
			cout<<'\n';
		editData(cdCode," CD Code: ",1000000000,9999999999);
			cout<<'\n';
			cin.ignore(1);

	system("pause");
	main();		
}
//*********************************************************************
//---------------------------------------------------------------------
//*********************************************************************
void existingMember(string secArray[][2])
{
cout<<"existingmember works! "<<endl;
}
//*********************************************************************
//---------------------------------------------------------------------
//*********************************************************************
//array function (state)
void stateArray(string& state)
{
	//declare variable
	string stateFound = "N";

		//loop while state is not found
		do	
		{
			//array declaration
			string stateArray[10];
			//US states
			//
			//rhode island
			stateArray[0] = "RI";
			//mass.
			stateArray[1] = "MA";
			//conn.
			stateArray[2] = "CT";

				//Canada provinces
				//
				//ontario
				stateArray[4] = "ON";
				//quebec
				stateArray[5] = "QC";
				//british columbia
				stateArray[6] = "BC";

			//Mexico states
			//
			//baja california
			stateArray[7] = "BJ";
			//chiapas
			stateArray[8] = "CH";
			//Chihuahua
			stateArray[9] = "CI";
			cout<<'\n';
			editData(state," State: ",2,2);
			transform(state.begin(),state.end(),state.begin(),toupper);
			//validation (input compared to array)
			for(int i = 0; i < 9; i++)
			{
				if(stateArray[i] == state)
				{
					stateFound = "Y";
					break;
				}
				else
				{
					stateFound = "N";
				}	
			}	
		}
		while(stateFound != "Y");	
}
//end of function (state)
//--------------------------------------------------------------------------
//array function (country)
void countryArray(string& country)
{
	//declare variable
	string countryFound = "N";

		//loop while state is not found
		do	
		{
			//array declaration
			string countryArray[3];
			//united states
			countryArray[0] = "USA";
			//canada
			countryArray[1] = "CAN";
			//mexico
			countryArray[2] = "MEX";
			cout<<'\n';
			editData(country," Country: ",3,3);
			transform(country.begin(),country.end(),country.begin(),toupper);
			//validation (input compared to array)
			for(int i = 0; i < 3; i++)
			{
				if(countryArray[i] == country)
				{
					countryFound = "Y";
					break;
				}
				else
				{
					countryFound = "N";
				}	
			}	
		}
		while(countryFound != "Y");	
}
//end of function (country)
//--------------------------------------------------------------------------
//search array function
int arraySearch(const string secArray[][2],const string& name,const string& callSign)
{	
	//declare variables used in array search
	int index = 0;
	bool found = false;
	int numNames = 10;
	//while it is not found and index is less than numNames
	while((!found)&&(index < numNames))
	{
		//if index is equal to the user input (name)
		if(secArray[index][0] == name)
		{
			if(secArray[index][1] == callSign)
			{
				found = true;
				break;
			}
		}
		else
		{
			//else increase index to search next index
			index++;
		}
	}	
		if(found)
		{
			//return the index it was found on
			return index;
		}
		else
		{
//else return -1 to say its not found, so now it is able to write to file
			return - 1;
		}
}
//--------------------------------------------------------------------------
int loadArray(string secArray[][2])
{
return 0;
}

Recommended Answers

All 5 Replies

Function prototype:
int loadArray(const string[][2]);

Function definition:
int loadArray(string secArray[][2])

Not the same signatures!
Do you really need/want the const qualifier in the prototype?

commented: Very very helpful A++++ +1

i think thats what my professor wants but ill review my notes and if not ill take both out. thx very much that helped me a whole lot now i can finally move on :)

I think you're missing my point. In your prototype, you have the parameter as const string[][2] and in the function definition as string[][2] - the only difference is the use of const. As the function name indicates it should be modifying the array, you don't want to put the const in the prototype.

oh i see what you mean! thx and sorry for being so blind :)

Everything is running smoothly and, i removed the const within my prototype because you was right. while using the const i wouldn't be able to change the value later on! :) much appreciated..... later

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.