unresolved external symbol

Im writing a code to calculate the cost for parking in a parking lot based on time and vehicle type. i know the code inst even closed to finished im just looking to get ride of the unresolved external because I've gotten in before and couldn't get rid of it.

my code:

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

void getdata (int* hourin, int* minin, int* hourout, int* minout);
void carcharges (int hourin, int minin, int hourout, int minout, int charge, int minutes, int hours);

void output (int hourin, int minin, int hourout, int minout,int roundedtime, int minutes, int hours);

int main (void)
{

char type;
int hourin;
int minin;
int hourout;
int minout;
int totalhours;
int charge;
int hours;
int minutes;
int roundedtime;
float total;

printf("Type of vehicle (c - t - b) ");
scanf("%c\n", &type);

getdata (&hourin, &minin, &hourout, &minout);


if (type == 100)
carcharges (hourin, minin, hourout, minout, charge, minutes, hours);
else if (type == 117)
printf("truck");
else if (type == 99)
printf("bus");
else
printf("Invalid");

output (hourin, minin, hourout, minout, roundedtime, minutes, hours);

system ("pause");
return 0;
}



void getdata (int* hourin, int* minin, int* hourout, int*minout)
{

printf("Hour vehicle entered lot(0 - 24)");
scanf("%5d", &hourin);
printf("Minute vehicle enterd lot(0 - 60)");
scanf("%5d", &minin);
printf("hour vehicle left lot (0 - 24)");
scanf("%5d", &hourout);
printf("Minute vehicle left lot (0 - 60");
scanf("%5d", &minout);
}

void carcharges (int* hourin, int* minin, int* hourout, int* minout, int charge, int minutes, int hours)
{

hours = hourout - hourin;

if (minout < minin)
hours -= 1;
else if (minout > minin)
hours += 1;
else
hours = hours;

minutes = abs(minin - minout);

if (hours < 3 && minutes < 60)
charge = 0;
else
charge = (hours -2) * 1.5;



return;
}



void output (int hourin, int minin, int hourout, int minout, int roundedtime, int minutes, int hours)
{
roundedtime = hours + 1;

printf("\t\t\t\t PARKING LOT CHARGE \n");
printf("Type of vehicle: \tfix this part\n");
printf("TIME-IN\t\t\t %d : %d\n", hourin, minin);
printf("TIME-OUT\t\t\t %d : %d\n", hourout, minout);
printf("\t\t\t\t --------\n");
printf("PARKING TIME\t\t %d : %d\n", hours, minutes);
printf("ROUNDED TOTAL\t\t %d\n", roundedtime);

return;
}

the error:

Error 13 error LNK2019: unresolved external symbol "void __cdecl carcharges(int,int,int,int,int,int,int)" (?carcharges@@YAXHHHHHHH@Z) referenced in function _main c:\Users\sspangler\documents\visual studio 2010\Projects\Project 4 pg 297\Project 4 pg 297\project 58.obj
You declare cracharges as taking only int parameters:
void carcharges (int hourin, int minin, int hourout, int minout, int charge, int minutes, int hours);

But then you define an overloaded version that takes some int pointers and ints:
void carcharges (int* hourin, int* minin, int* hourout, int* minout, int charge, int minutes, int hours)

You either need to change the declaration or the definition.
That fixed it thanks for the help. I don't mean to be a burden but my teacher doesn't really teach. now its saying that when i call the output function hours, minutes and charge are being called without being initialized.
If you used the pointer version of the function, when you call the function you need to use the & operator on the variables. I'd recommend using references instead.
Hi,
This can also be converted into class .

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#include <stdio.h>
#include <iostream.h>
#include <stdlib.h>
#include <math.h>

class CCompleateTime 
{
	private:
		char type;
		int hourin;
		int minin;
		int hourout;
		int minout;
		int totalhours;
		int charge;
		int hours;
		int minutes;
		int roundedtime;
		float total;

		public:
			CCompleateTime () : type (''), hourin(0), minin(0) , hourout(0) ,  minout(0),  totalhours(0),  charge(0), hours (0) , minutes(0) ,roundedtime(0),		total(0.0) { }
			~CCompleateTime () { } 

			void getData ();
			void carCharges ();
			void output ();



};

void CCompleateTime :: getData ()
{
	cout<<"Hour vehicle entered lot(0 - 24)";
	cin>>hourin;
	cout"Minute vehicle enterd lot(0 - 60)";
	cin>>minin;
	cout>>"hour vehicle left lot (0 - 24)";
	cin>>hourout;
	cout<<"Minute vehicle left lot (0 - 60";
	cin>>minout;
}
void CCompleateTime ::carCharges ()
{
		hours = hourout - hourin;
		if (minout < minin)
			hours -= 1;
		else if (minout > minin)
			hours += 1;
		else
			hours = hours;

		minutes = abs(minin - minout);

		if (hours < 3 && minutes < 60)
			charge = 0;
		else
			charge = (hours -2) * 1.5;
}
void CCompleateTime ::output ()
{
		roundedtime = hours + 1;
		cout<<"\t\t\t\t PARKING LOT CHARGE \n";
		cout<<"\"Type of vehicle: \tfix this part\n");
		cout<<"\"TIME-IN\t\t\t" << hourin<<": "<<minin<<"\n";
		cout<<"\"TIME-OUT\t\t\t"<<hourout<<":"<<minout<<"\n";
		cout<<"\"\t\t\t\t --------\n";
		cout<<"PARKING TIME\t\t "<< hours<<":"<<minutes<<"\n";
		cout<<"\"ROUNDED TOTAL\t\t "<< roundedtime<<"\n";
}

int main (void)
{

int type = 0 ;
CCompleateTime ccomTime ; 
cout<<"Type of vehicle (c - t - b) ";
cin>>type;

ccomTime.getdata ();
if (type == 100) 
ccomTime.carcharges ();
else if (type == 117)
cout<<"truck\n";
else if (type == 99)
cout<<"bus\n";
else
cout<<"Invalid\n";

ccomTime.output ();

system ("pause");
return 0;
}

Last edited on
when i have them input the type of vehicle i need to be able to tell what function to call but when i try to test it and i put in c, t or b it just goes right over the if statement and goes to the output function.

if (type == 'c')
carcharges (&hourin, &minin, &hourout, &minout, charge, minutes, hours);
else if (type == 't')
printf("truck");
else if (type == 'b')
printf("bus");

this is what i have right now, how to i make it so it actually uses the if statement.
Or if a switch statement would work better i can use that too
Topic archived. No new replies allowed.