how can I fix this?

I wrote a program and when I try to compile it, these errors keep coming out and I don't know what to do.

1>c:\desktop\lab8\lab8\lab8.cpp(7) : error C2447: '{' : missing function header (old-style formal list?)
1>c:\desktop\lab8\lab8\lab8.cpp(53) : error C2447: '{' : missing function header (old-style formal list?)
1>Build log was saved at "file://c:\Desktop\lab8\lab8\Debug\BuildLog.htm"


how can I fix this?
There isn't much we can do without code.
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
#include<fstream>
#include<string>
#include<iostream>
using namespace std;
{int main();
class customer;
	char name[100], s;
	float cost;
	int occupants;


	class customer()
	
		{strcpy_s(name,"noname");
		cost = 0.0;
		occupants = 0;}

	customer(char* n, float c, int o)
	
	{strcpy_s(name,n);
		cost = c;
		occupants = o;}

	char* getName()
	
		{return name;}
	
	float getCost()
	
		{return cost;}
	

	int getOccupants()
		
		{return occupants;}

	void setName(char* n)
	
		{strcpy_s(name,n);}

	void setCost(float c)
	
		{cost = c;}

	void setOccupants(int o)
	
	{occupants = o;}

}

	{class customer c[100],temp;
	char* s;
	float f;
	int i=-1,occ,n,choice,t=1,j;
	ifstream infile;
	infile.open ("C:\\Desktop\\HISD.txt",ios::in);

	while(!infile.eof())
	
		i++;
		infile>>s;
		c[i].setName(s);
		infile>> f;
		c[i].setCost(f);
		infile>> occ;
		c[i].setOccupants(occ);
	
	infile.close();
	n = i;
	cout << "\n Read from file Success.";
	while(t == 1)
	{
		cout << "\n";
		cout << "\n 1. Display Records";
		cout << "\n 2. Sort by Customer Name";
		cout << "\n 3. Find Median Cost";
		cout << "\n 4. Exit";
		cout << "\n Please enter choice: ";
		cin >> choice;
		switch(choice)
		{
			case 1:
			for(i=0;i<n;i++)
			{
			cout << "\n " << c[i].getName();
			cout << "\t " << c[i].getCost();
			cout << "\t " << c[i].getOccupants();
			}
			break;

			case 2:
			//bubble sort name
			for(i = 1; i < n; i++)
     			{
          			for (j=0; j < n-1; j++)
         			{
               				if (_stricmp(c[j+1].getName(),c[j].getName()) < 0)
					{ 
                    				temp.setName(c[j].getName());             // swap elements
						temp.setCost(c[j].getCost());
						temp.setOccupants(c[j].getOccupants());

                    				c[j].setName(c[j+1].getName());
                    				c[j].setCost(c[j+1].getCost());
                    				c[j].setOccupants(c[j+1].getOccupants());

                    				c[j+1].setName(temp.getName());
                    				c[j+1].setCost(temp.getCost());
                    				c[j+1].setOccupants(temp.getOccupants());
                    			}
          			}
     			}
			cout << "\n Sorted Records: ";
			for(i=0;i<n;i++)
			{
			cout << "\n " << c[i].getName();
			cout << "\t " << c[i].getCost();
			cout << "\t " << c[i].getOccupants();
			}
			break;

			case 3:
			//bubble sort cost
			for(i = 1; i < n; i++)
     			{
          			for (j=0; j < n-1; j++)
         			{
               				if (c[j+1].getCost() < c[j].getCost())
					{ 
                    				temp.setName(c[j].getName());             // swap elements
						temp.setCost(c[j].getCost());
						temp.setOccupants(c[j].getOccupants());

                    				c[j].setName(c[j+1].getName());
                    				c[j].setCost(c[j+1].getCost());
                    				c[j].setOccupants(c[j+1].getOccupants());

                    				c[j+1].setName(temp.getName());
                    				c[j+1].setCost(temp.getCost());
                    				c[j+1].setOccupants(temp.getOccupants());
                    			}
          			}
     			}

			// find mid
			if (n%2 == 0)
			
				{cout << "\n There are two median costs:";
				cout << "\n " << n/2;
				cout << " : Median 1 :" << c[n/2].getName();
				cout << "\t " << c[n/2].getCost();
				cout << "\t " << c[n/2].getOccupants();
				cout << "\n " << n/2+1;
				cout << " : Median 2 :" << c[n/2+1].getName();
				cout << "\t " << c[n/2+1].getCost();
				cout << "\t " << c[n/2+1].getOccupants();}
			else
			
				{cout << "\n There is a single median cost:";
				cout << "\n " << n/2+1;
				cout << " : Median :" << c[n/2].getName();
				cout << "\t " << c[n/2].getCost();
				cout << "\t " << c[n/2].getOccupants();}
			break;

			case 4:
			t=0;
			break;

			default:
			cout <<"\n Please Enter valid choice.";
			break;
		}
	}
	cout<<"Have a great day.";
	return 0;}


Line 5: {int main (); What is this meant to be? Did you mean int int main(){?
Line 6: Did you mean class customer{?
Line 51: Now you lost me.

I think you may need to review basic syntax.
Last edited on
Topic archived. No new replies allowed.