3 Replies - 676 Views - Last Post: 25 July 2010 - 10:38 AM Rate Topic: -----

#1 Drj312  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 42
  • Joined: 28-June 10

error LNK2019 and fatal error LNK1120

Posted 25 July 2010 - 10:18 AM

where is the problem?

#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstring>
using namespace std;

const int MAX_CLIENT_SIZE = 100;
const int FIRST_NAME_LEN = 11;
const int LAST_NAME_LEN = 13;
const int ADDRESS_LEN = 25;
const int CITY_NAME_LEN = 16;
const int STATE_LEN = 3;

struct CustomerType
{
	char lastName[LAST_NAME_LEN];
	char firstName[FIRST_NAME_LEN];
	char streetAddress[ADDRESS_LEN];
	char city[CITY_NAME_LEN];
	char state[STATE_LEN];
	int zipCode;
};

void reportHeading(ostream& outfile);
int getInfo(CustomerType struct_array[], istream& infile, int& count);
void printCustomers(ostream& outfile, CustomerType output[], int count);

int main()
{
	int count;
	CustomerType clients[MAX_CLIENT_SIZE];

	ifstream infile("PJ902_customers.txt");
	if (!infile){
		cerr << "File loading failed.\n";
		return -1;
	}
	ofstream outfile("PJ902_report.txt");
	if (!outfile)
	{
		cerr << "File output failed.\n";
		return -1;
	}
	reportHeading(outfile);
	int actualCount;
	actualCount = getInfo(clients, infile, count);
	printCustomers(outfile, clients, actualCount);



}

void reportHeading(ostream& outfile)
{
	outfile << setw(30) << "Customer Information Report\n";
	outfile <<	"Reported by Josh Panfil\n\n\n";
	outfile << setw(10) << "First Name" << setw(10) << "Last Name" << setw(9) << "Address"
		<< setw(20) << "City" << setw(5) << "State" << setw(10) << "Zip Code\n";
	outfile << setw(10) << "--------" << setw(10) << "---------" << setw(9) << "---------"
		<< setw(20) << "---------" << setw(5) << "------" << setw(10) << "------\n";
	
}

int getInfo(CustomerType struct_array[], istream& infile, int& count)
{
	int index = 0;

	infile.get(struct_array[index].firstName, FIRST_NAME_LEN);
	infile.get(struct_array[index].lastName, LAST_NAME_LEN);
	infile.get(struct_array[index].streetAddress, ADDRESS_LEN);
	infile.get(struct_array[index].city, CITY_NAME_LEN);
	infile.get(struct_array[index].state, STATE_LEN);
	infile >> struct_array[index].zipCode;

	while( index < MAX_CLIENT_SIZE && infile )
	{
		index++;
		infile >> ws;

		infile.get(struct_array[index].firstName, FIRST_NAME_LEN);
		infile.get(struct_array[index].lastName, LAST_NAME_LEN);
		infile.get(struct_array[index].streetAddress, ADDRESS_LEN);
		infile.get(struct_array[index].city, CITY_NAME_LEN);
		infile.get(struct_array[index].state, STATE_LEN);
		infile >> struct_array[index].zipCode;
	}

	count = index;

	//Test the file status after reading in the data
	 if( index == MAX_CLIENT_SIZE && infile >> ws && infile.good() )
		 return 1; //indicator value for too many data
	 else if( !infile.eof() && infile.fail() )
	 	 return -1; //indicator value for bad data
	 else
		 return 0; //everything was successful
}

void printCustomers(ostream& outfile, CustomerType output[], int& actualCount)
{
	for (int i = 0; i < actualCount; i++){
		outfile << output[i].firstName << output[i].lastName << output[i].streetAddress
			<< output[i].city << output[i].state << output[i].zipCode << endl;
	}
}


errors

Quote

error LNK2019: unresolved external symbol "void __cdecl printCustomers(class std::basic_ostream<char,struct std::char_traits<char> > &,struct CustomerType * const,int)" (?printCustomers@@YAXAAV?$basic_ostream@DU?$char_traits@D@std@@@std@@QAUCustomerType@@H@Z) referenced in function _main

fatal error LNK1120: 1 unresolved externals


Is This A Good Question/Topic? 0
  • +

Replies To: error LNK2019 and fatal error LNK1120

#2 sarmanu  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 966
  • View blog
  • Posts: 2,362
  • Joined: 04-December 09

Re: error LNK2019 and fatal error LNK1120

Posted 25 July 2010 - 10:22 AM

Prototype:
void printCustomers(ostream& outfile, CustomerType output[], int count);


and implementation:
void printCustomers(ostream& outfile, CustomerType output[], int& actualCount)


Take a look at third parameter type. Do the comparison.
Was This Post Helpful? 0
  • +
  • -

#3 Drj312  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 42
  • Joined: 28-June 10

Re: error LNK2019 and fatal error LNK1120

Posted 25 July 2010 - 10:26 AM

thank you. jeez i suck
Was This Post Helpful? 0
  • +
  • -

#4 Drj312  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 42
  • Joined: 28-June 10

Re: error LNK2019 and fatal error LNK1120

Posted 25 July 2010 - 10:38 AM

my data input is not working. can someone please tell me why?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1