unresolved external symbol?

i'm having a rough time with this. This is actually a program I was trying to help someone else out on and in the process i've run into this unresolved external symbol error for double temp1[]. i've tried a variety of different things to fix it. googled it ect. for w-e reason i can't make it go away unless I eliminate the array entirely. Not understanding if my usage of the array is wrong or what the deal is. Can someone please explain why i'm getting this error? An tell me how to fix. Thanx in advance

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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#include <iostream>

using namespace std;
double ccin();
//void menu(); // functions
double calculate(double in); // functions
void display(); // functions
double checkout(double temp1[],int i);
int choice;
//int i=0;
double total;
double temp;
double in;
double temp1[];
int a;
double in1[];
void ccin(double in);
void getprices();int* i=0;
int main()
{
cout<<"1- To Enter Item Prices "<<endl;
cout<<"2- To Display Total"<<endl;
cout<<"3- TO QUIT: )"<<endl;
cin>>choice;
switch (choice)
{
case 1:
	
	getprices();


break;
case 2:
display();
break;
case 3:
break;
}

return 0;
}




//double temp1[];
//double temp[];
//void calculate()
//{
//;
//cout<<"Enter item Price (negative to Quit):\n "<<endl;
//while(i=0,temp1[i]>0)
//{

//cin>>temp1[i];
//if(temp<=0)
	//break;

//else
//total+=temp1[i]*1.08;
//i++;
//}
//menu();
//}


void display()
{
	cout<<" The total price of all items, including 8% tax is $"<<total<<endl;}

//menu();} // would add delay b4 this



//in milliseconds
void delay(double x)     
{
	int y;
	for(y=0;y<x;y++)
	((x *10000)/.01);

}


void checkout(double temp1[],int i)
	{int z;

for(z=0;z<i;z++)
{  temp += temp1[z] ;

}
total=temp;

cout<<"Total is"<<total;
delay(5000);


}

//void ccin(double in)

//{
	
	//int i;







//}





void getprices()
{	int i;
	in=1;
	while(i=0,in>0)
cout<<"Enter item Price (negative to Quit):\n ";
	cin>>in;
	temp1[i]=in;i++;
	
	
	a=i;	checkout(temp1,a);







}
Last edited on
1
2
3
double temp1[];
//...
double in1[];


You have to give a size for these arrays. You can't leave the brackets empty.
should i just punch in a number that I think is above what anyone would reasonably enter into this program? Bc the size is based upon the number of user inputs how can I define an unknown like that?
should i just punch in a number that I think is above what anyone would reasonably enter into this program?


That's one approach. Though if the user enters a number higher than that you'll have problems. One way to prevent that would be to stop accepting input once you reach that limit.

Another option would be to use a vector, which basically is a resizable array, so you can keep adding new elements to the end of it without having to define a fixed size.
Another option is to use new to allocate the amount of memory you need when you find out from the user. Using a vector is definitely a better option, though.
The new approach works best if the user tells you upfront how many items they'll be giving you.

It doesn't work so well for "keep going until they give me a negative value" type situations. But yeah it is another option.
sweet, I played around with this w/o the above info till my head exploded. So my hat sits a lil lower now. I will take the advice an try it out tomorrow.
Topic archived. No new replies allowed.