can anyone be specific with me on trying to figure out this error....I have been reaqding my book and looking all over the net trying to solve it but all i have left is these two errors!!!!!!!

#include <iostream>
#include <string>
#include <fstream>

using namespace std;

void add_Record();
void get_Record();


void DisplayMenu();
int GetChoice();
bool Confirm();
void ProcessChoice(int);



int main()
{
	int choice;
	bool quit = false;
	do
	{
		DisplayMenu();
		choice = GetChoice();
		if ( choice == 0 )
		{
			if (Confirm())
			quit = true;
		}
		else
			ProcessChoice(choice);

	}while (!quit);

	return 0;
}

void DisplayMenu()
{
	cout << "1) Enter new patient\n";
	cout << "2) List all smokers\n";
	cout << "3) List all Male smokers\n";
	cout << "4) List all Female smokers\n";
	cout << "5) List all with risk factor greater than 5\n";
	cout << "6) List all with risk factor less than 5\n";
	cout << "7) Search by SS number\n";
	cout << "8) List all by an age\n";
	cout << "9) List all with HBP and HFD\n";
	cout << "10) List Counts of Smokers, HFD, and HBP\n";
	cout << "0) Exit\n";
}

int GetChoice()
{
	int choice;
	cout << " Enter a choice ";
	cin >> choice;
	return choice;
}

bool Confirm()
{
	char choice = 'N';
	bool rsp = false;
	bool done = false;
	do
	{
		cout<<" Are you sure to quit (Y/N)? ";
		cin >> choice;
		choice = toupper (choice);
		if (choice == 'Y')
			rsp = true;

		if (choice == 'Y' || choice == 'N') 
			done = true;
		else
			done = false;

	}while (!done);

	return rsp;
}
void ProcessChoice(int c) 
{
	
	switch (c)
{
	       
	case 1:
		 add_Record();
		{
			ofstream outFile;
			outFile.open ("records.dat", ios::app);

					
			string name;
			char gender;
			int age;
			int ss;
			int smoke;
			int HBP;
			int HFD;
			int points;
			
			cout << "Name: ";
			cin >> name;
			cout << "Gender: ";
			cin >> gender;
			cout << "Age: ";
			cin >> age;
			cout << "SSN: ";
			cin >> ss;
			cout << "Smoke: ";
			cin >> smoke;
			cout << "HBP (0/1):";
			cin >> HBP;
			cout << "HFD (0/1):";
			cin >> HFD;
			cout << "points (0/1):";
			cin >> points;
			
			outFile << name <<",";
			outFile << gender <<" ";
			outFile << age <<" ";
			outFile << ss <<" "; 
			outFile << smoke <<" ";
			outFile << HBP <<" ";
			outFile << HFD <<" ";
			outFile << points << endl;
			outFile.close();
			return;
		}
			break;

		
	case 2:
			get_Record();
			{
			ifstream inFile;

			inFile.open ("records.dat", ios_base::in);
			string name;
			char gender;
			int age;
			int ss;
			int smoke;
			int HBP;
			int HFD;
			int points;

			if (inFile.is_open())
			{
				getline(inFile, name, ',');

				inFile >> gender >> age >> ss >> smoke >> HBP >> HFD >> points; 

				cout << name <<", "<<"Gender: "<<gender<<", "<<"Age: "<<age<<", "<<"SS# "<<ss<<", ";
				if (smoke == 1)
					cout <<"Smoker, ";
				else 
					cout <<"Non Smoker, ";

				system ("pause");
			}
			else
				cout<<"File could not be opened.\n";
			inFile.close();
			return;
			}
		
	break;
	case 3:
		 get_Record();
		{
	
			ifstream inFile;
			inFile.open ("records.dat", ios::in);
			string name;
			char gender;
			int age;
			int ss;
			int smoke;
			int HBP;
			int HFD;
			int points;

			if (inFile.is_open())
			{
				getline(inFile, name, ',');

				inFile >> gender >> age >> ss >> smoke >> HBP >> HFD >> points; 

				cout<<name<<", "<<"Gender: "<<gender<<", "<<"Age: "<<age<<", "<<"SS# "<<ss<<", ";
				if (smoke ==1 && gender == 'M')
					cout <<"Smoker, ";
				else 
					cout <<"Non Smoker, ";

				system ("pause");
			}
			else
				cout<<"File could not be opened.\n";
		}

	break;
	case 4:
		 get_Record();
		{
	
			ifstream inFile;
			inFile.open ("records.dat", ios::in);
			string name;
			char gender;
			int age;
			int ss;
			int smoke;
			int HBP;
			int HFD;
			int points;

			if (inFile.is_open())
			{
				getline(inFile, name, ',');

				inFile >> gender >> age >> ss >> smoke >> HBP >> HFD >> points; 

				cout<<name<<", "<<"Gender: "<<gender<<", "<<"Age: "<<age<<", "<<"SS# "<<ss<<", ";
				if (smoke ==1 && gender == 'F')
					cout <<"Smoker, ";
				else 
					cout <<"Non Smoker, ";
				system ("pause");
			}
			else
				cout<<"File could not be opened.\n";
		}

	break;
	case 5:
		 get_Record();
		{
	
			ifstream inFile;
			inFile.open ("records.dat", ios::in);
			string name;
			char gender;
			int age;
			int ss;
			int smoke;
			int HBP;
			int HFD;
			int points;

			if (inFile.is_open())
			{
				getline(inFile, name, ',');

				inFile >> gender >> age >> ss >> smoke >> HBP >> HFD >> points; 

				cout<<name<<", "<<"Gender: "<<gender<<", "<<"Age: "<<age<<", "<<"SS# "<<ss<<", ";
				if (points >= 5)
					cout <<"Risk Factors Greater Than 5, ";
				else 
					cout <<"Non Risk Factors Greater Than 5, ";

				system ("pause");
			}
			else
				cout<<"File could not be opened.\n";

		}

	break;
	case 6:
		 get_Record();
		{
	
			ifstream inFile;
			inFile.open ("records.dat", ios::in);
			string name;
			char gender;
			int age;
			int ss;
			int smoke;
			int HBP;
			int HFD;
			int points;

			if (inFile.is_open())
			{
				getline(inFile, name, ',');

				inFile >> gender >> age >> ss >> smoke >> HBP >> HFD >> points; 

				cout<<name<<", "<<"Gender: "<<gender<<", "<<"Age: "<<age<<", "<<"SS# "<<ss<<", ";
				if (points <= 5)
					cout <<"Risk Factors Less Than 5, ";
				else 
					cout <<"Non Risk Factors Less Than 5, ";

				system ("pause");
			}
			else
				cout<<"File could not be opened.\n";

		}
	break;
	case 7:
		 get_Record();
		{
			ifstream inFile;
			inFile.open ("records.dat", ios::in);
			string name;
			char gender;
			int age;
			int ss;
			int smoke;
			int HBP;
			int HFD;
			int points;

			if (inFile.is_open())
			{
				getline(inFile, name, ',');

				inFile >> gender >> age >> ss >> smoke >> HBP >> HFD >> points; 

				cout<<"SS# "<<ss<<", "<<name<<", "<<"Gender: "<<gender<<", "<<"Age: "<<age<<", ";
		
				system ("pause");
			}
			else
				cout<<"File could not be opened.\n";
		
		}

	break;
	case 8:
		 get_Record();
		{
	
			ifstream inFile;
			inFile.open ("records.dat", ios::in);
			string name;
			char gender;
			int age;
			int ss;
			int smoke;
			int HBP;
			int HFD;
			int points;
			if (inFile.is_open())
			{
				getline(inFile, name, ',');

				inFile >> gender >> age >> ss >> smoke >> HBP >> HFD >> points; 
				cout<<"Age: "<<age<<", "<<name<<", "<<"Gender: "<<gender<<", "<<"SS# "<<ss<<", ";
		
				system ("pause");
			}
			else
				cout<<"File could not be opened.\n";
		}

	break;
	case 9:
		 get_Record();
		{
			ifstream inFile;
			inFile.open ("records.dat", ios::in);
			string name;
			char gender;
			int age;
			int ss;
			int smoke;
			int HBP;
			int HFD;
			int points;

			if (inFile.is_open())
			{
				getline(inFile, name, ',');

				inFile >> gender >> age >> ss >> smoke >> HBP >> HFD >> points; 

				cout<<name<<", "<<"Gender: "<<gender<<", "<<"Age: "<<age<<", "<<"SS# "<<ss<<", ";
		
				if (HBP ==1 && HFD == 1)
					cout <<"HBP and HFD, ";
				else
					cout << "No HBP and HFD, ";

				system ("pause");
			}
			else
				cout<<"File could not be opened.\n";
		}

	break;
	
	default:
		cout<<"wrong choice!\n";
		
	} ;

}

 void add_Record()
{
	{
	ofstream outFile;
	outFile.open ("records.dat", ios::app);
	string name = "Ms. Johnson";
	char gender = 'F'
		;
	int age = 33;
	int ss  = 123456788;
	int smoke = 0;
	int HBP = 0;
	int HFD = 1;
	int points = 4;


	outFile << name <<",";			
	outFile << gender <<" ";		
	outFile << age <<" ";			
	outFile << ss <<" ";			
	outFile << smoke <<" ";			
	outFile << HBP <<" ";			
	outFile << HFD <<" ";			
	outFile << points << endl;		

	outFile.close();
	return;
	}

{
	ofstream outFile;
	outFile.open ("records.dat", ios::app);
	string name = "Mr. Kime";
	char gender = 'M'
		;
	int age = 19;
	int ss  = 123456888;
	int smoke = 0;
	int HBP = 1;
	int HFD = 1;
	int points = 4;


	outFile << name <<",";			
	outFile << gender <<" ";		
	outFile << age <<" ";			
	outFile << ss <<" ";			
	outFile << smoke <<" ";			
	outFile << HBP <<" ";			
	outFile << HFD <<" ";			
	outFile << points << endl;		

	outFile.close();
	return;
}

{
	ofstream outFile;
	outFile.open ("records.dat", ios::app);
	string name = "Mrs. White";
	char gender = 'F'
		;
	int age = 50;
	int ss  = 124356788;
	int smoke = 0;
	int HBP = 1;
	int HFD = 1;
	int points = 6;


	outFile << name <<",";			
	outFile << gender <<" ";		
	outFile << age <<" ";			
	outFile << ss <<" ";			
	outFile << smoke <<" ";			
	outFile << HBP <<" ";			
	outFile << HFD <<" ";			
	outFile << points << endl;		

	outFile.close();
	return;
}

{
	ofstream outFile;
	outFile.open ("records.dat", ios::app);
	string name = "Mr. Long";
	char gender = 'M'
		;
	int age = 27;
	int ss  = 121116788;
	int smoke = 1;
	int HBP = 1;
	int HFD = 0;
	int points = 8;


	outFile << name <<",";			
	outFile << gender <<" ";		
	outFile << age <<" ";			
	outFile << ss <<" ";			
	outFile << smoke <<" ";			
	outFile << HBP <<" ";			
	outFile << HFD <<" ";			
	outFile << points << endl;		

	outFile.close();
	return;
}

{
	ofstream outFile;
	outFile.open ("records.dat", ios::app);
	string name = "Mrs. Hughes";
	char gender = 'F'
		;
	int age = 43;
	int ss  = 123452768;
	int smoke = 1;
	int HBP = 1;
	int HFD = 1;
	int points = 10;


	outFile << name <<",";			
	outFile << gender <<" ";		
	outFile << age <<" ";			
	outFile << ss <<" ";			
	outFile << smoke <<" ";			
	outFile << HBP <<" ";			
	outFile << HFD <<" ";			
	outFile << points << endl;		

	outFile.close();
	return;
}

{
	ofstream outFile;
	outFile.open ("records.dat", ios::app);
	string name = "Ms. Flinstone";
	char gender = 'F'
		;
	int age = 17;
	int ss  = 124533248;
	int smoke = 0;
	int HBP = 0;
	int HFD = 1;
	int points = 2;


	outFile << name <<",";			
	outFile << gender <<" ";		
	outFile << age <<" ";			
	outFile << ss <<" ";			
	outFile << smoke <<" ";			
	outFile << HBP <<" ";			
	outFile << HFD <<" ";			
	outFile << points << endl;		

	outFile.close();
	return;
}
}

here are the errors:

1>main.obj : error LNK2019: unresolved external symbol "void __cdecl get_Record(void)" (?get_Record@@YAXXZ) referenced in function "void __cdecl ProcessChoice(int)" (?ProcessChoice@@YAXH@Z)
1> fatal error LNK1120: 1 unresolved externals

1> 2 error(s), 0 warning(s)

help please

Recommended Answers

All 5 Replies

First, that is a linker error - it seems you have not defined ProcessChoice(int) in an appropriate place. Also, surely 99% of those lines of code have nothing to do with the problem. Pare down the code to about 20 lines that produces the same problem and then we can take a look. You may also want to use code=cplusplus so syntax highlighting gets used.

The error message is quite clear -- you failed to code the function named get_record().

He hasn't just failed in coding the function AncientDragon he literally hasn't coded get get_record() ... ;)

And very bad coding style with the functions process_choice() and add_record() you are calling the functions but inserting the record literally whats the use man ??? Take the inputs from user and feed... If you want to do the same for 100 records according to your function you need to write in 100 records into program yourself. Thats bad.

You have just removed the essence of calling functions,the whole concept of modulation is gone here.

commented: Couldn't agree more :) +36

well how would i fix this?...I took am online self tought computer programming class so things are not that clear to me...

I usually write down a code as best as I can and then try to fix everything up by what the errors say...I know it is a bad approach but I dont know what else to do..

Ok, here is some help -- I've reworked part of that function, you should be able to finish it. There are more you could do to make it even better, but we'll just start with this format. Write the other case statements in a format similar to the one I wrote for case 2.

void ProcessChoice(int c) 
{
    string line;
	string name;
	char gender;
	int age;
	int ss;
	int smoke;
	int HBP;
	int HFD;
	int points;
	ofstream outFile;
	ifstream inFile;
	
    switch (c)
    {      
        case 1: // Enter new patient
            outFile.open ("records.dat", ios::app);
            cout << "Name: ";
            cin >> name;
            cout << "Gender: ";
            cin >> gender;
            cout << "Age: ";
            cin >> age;
            cout << "SSN: ";
            cin >> ss;
            cout << "Smoke: ";
            cin >> smoke;
            cout << "HBP (0/1):";
            cin >> HBP;
            cout << "HFD (0/1):";
            cin >> HFD;
            cout << "points (0/1):";
            cin >> points;
			
            outFile << name <<",";
            outFile << gender <<" ";
            outFile << age <<" ";
            outFile << ss <<" "; 
            outFile << smoke <<" ";
            outFile << HBP <<" ";
            outFile << HFD <<" ";
            outFile << points << endl;
            outFile.close();
        break;

		
	case 2: // List All Smokers
            inFile.open ("records.dat");
            if (inFile.is_open())
            {
                while( getline(inFile, line) )
                {
                    stringstream str(line);
                    getline(str, name, ',');
                    str >> gender >> age >> ss >> smoke >> HBP >> HFD >> points; 
                    if (smoke == 1)
                        cout << name <<", "<<"Gender: "<<gender<<", "<<"Age: "<<age<<", "<<"SS# "<<ss<<"\n";
                }
                cout << "Press Enter when ready\n";
                cin.get();
            }
            else
                cout<<"File could not be opened.\n";
	    break;
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.