Entry point must be defined error

I am writing a program that should merge two files, sort and update one of the files, and output the results to several different files. I have the following code trimmed down to one error:"Entry point must be defined" and i cannot figure out what is going wrong:

#include<iostream>
#include<string>
#include<fstream>
#include<cstdlib>
#include<iomanip>
#include <cctype>
using namespace std;

int main();

struct
cust_record{

char
Trans_type;

string Cust_ID;

string LName;

string FName;

double
Balance;

int
Credit_limit;

char
Status;};

struct
master_record{

string Cust_ID;

string LName;

string FName;

double
Balance;

int
Credit_limit;

char
Status;};

bool
cust_ID_validator(string str1){

bool
flag;


if
(str1.length() != 7) flag = false;

else
if(!isdigit (str1.at

(0))) flag = false;

else
if(!isdigit (str1.at

(1)))flag = false;

else
if(!isdigit (str1.at

(2))) flag = false;

else
if(!isalpha (str1.at

(3))) flag = false;

else
if(!isdigit (str1.at

(4))) flag = false;

else
if(!isdigit (str1.at

(5))) flag = false;

else
if(!isdigit (str1.at

(6)))flag = false;

else

flag =
true;

return
flag;}

istream&
operator >> (istream& IS, cust_record& what) {

IS >> what.Trans_type;

if
(what.Trans_type == 'D')

IS >> what.Cust_ID;

else
//if((what.Trans_type == 'A')|| (what.Trans_type == 'E'))

IS >> what.Cust_ID >> what.LName >> what.FName >> what.Balance >> what.Credit_limit >> what.Status;

return
IS;}

ostream&
operator << (ostream& OS, cust_record what){

if
(what.Trans_type == 'D')

OS << what.Trans_type << setw(10) << what.Cust_ID;

else

OS << what.Cust_ID << setw(10) << what.LName << setw(10) << what.FName << setw(10) << what.Balance << setw(10) << what.Credit_limit << setw(10) << what.Status;

return
OS;}

istream&
operator >> (istream& IS, master_record& what){

IS >> what.Cust_ID >> what.LName >> what.FName >> what.Balance >> what.Credit_limit >> what.Status;

return
IS;}

ostream&
operator << (ostream& OS, master_record what){

OS << what.Cust_ID << setw(10) << what.LName << setw(10) << what.FName << setw(10) << what.Balance << setw(10) << what.Credit_limit << setw(10) << what.Status;

return
OS;}

master_record edit_master( cust_record struct1, master_record& struct2){

if
(struct1.Status != 'z')

struct2.Status = struct1.Status;

if
(struct2.Status != 'H')

if
(struct1.Balance <= (struct2.Balance/2))

struct2.Status =
'O';

if
(struct1.LName != "zzz")

struct2.LName = struct1.LName;

if
(struct1.FName != "zzz")

struct2.FName = struct1.FName;

if
(struct1.Balance != -9999)

struct2.Balance = struct1.Balance;

if
(struct1.Credit_limit != -9999)

struct2.Credit_limit = struct1.Credit_limit;

return
struct2;}

void
swap(cust_record data[], int i, int j){

cust_record temp;

temp = data[i];

data[i] = data[j];

data[j] = temp;}

void
sort(cust_record data[],int size){

for
(int m=0; m<size-1; m++)

for
(int n=0; n<(size-1)-m; n++)

if
(data[n].Cust_ID > data[n+1].Cust_ID)

swap(data, n, n+1);}

void
SortTransactionFile(){

int
i = 0;

cust_record data[100];

ifstream transaction;

transaction.open(
"transaction.txt");

ofstream error_log;

error_log.open(
"error_log.txt");

while
(!transaction.eof()){

transaction >> data[i];

i++;}

i--;

transaction.close();

sort(data, i);

ofstream Transaction;

Transaction.open(
"transaction.txt");

for
(int a = 0; a < i; a++){

if
(cust_ID_validator(data[a].Cust_ID)){

if
((data[a].Trans_type == 'A')||(data[a].Trans_type == 'E'))

Transaction << data[a].Trans_type <<
"\t" << data[a] << endl;

else

Transaction << data[a] << endl;}

else
{

if
((data[a].Trans_type == 'A')||(data[a].Trans_type == 'E'))

Transaction << data[a].Trans_type <<
"\t" << data[a] << endl;

else
if(data[a].Trans_type == 'D')

Transaction << data[a] << endl;

else
{

if
((data[a].Trans_type == 'A')||(data[a].Trans_type == 'E'))

error_log << data[a].Trans_type <<
"\t" << data[a] << ":\tCustomer ID invalid" << endl;

else
if(data[a].Trans_type == 'D')

error_log << data[a] <<
":\tCustomer ID invalid" << endl;}}}

Transaction.close();

error_log.close();

return ;
}
This code is horrid...

int main();

I'm guessing you meant to do this instead?

1
2
int main()
{
Adding a bracket after the main results in this error: IntelliSense: identifier "cust_record" is undefined" 12 times, and also the error:

error C2447: '{' : missing function header (old-style formal list?)

I have looked online for these errors and cannot find anything helpful.

The problem consists after closing the bracket.
Problem is you don't even have a main defined, hard to tell with messy code like that, so I cleaned it up.
It would probably help you a lot in the future if you tried to style your code similar to this
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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
#include<iostream>
#include<string>
#include<fstream>
#include<cstdlib>
#include<iomanip>
#include <cctype>

using namespace std;

struct cust_record
{
	char Trans_type;
	string Cust_ID;
	string LName;
	string FName;
	double Balance;
	int Credit_limit;
	char Status;
};

struct master_record{
	string Cust_ID;
	string LName;
	string FName;
	double Balance;
	int Credit_limit;
	char Status;
};


bool cust_ID_validator(string str1)
{
	bool flag;

	if (str1.length() != 7) 
		flag = false;

	else if(!isdigit (str1.at(0))) 
		flag = false;

	else if(!isdigit (str1.at(1)))
		flag = false;

	else if(!isdigit (str1.at(2))) 
		flag = false;

	else if(!isalpha (str1.at(3))) 
		flag = false;

	else if(!isdigit (str1.at(4))) 
		flag = false;

	else if(!isdigit (str1.at(5))) 
		flag = false;

	else if(!isdigit (str1.at(6)))
		flag = false;

	else
		flag = true;

	return flag;
}

istream& operator >> (istream& IS, cust_record& what) 
{
	IS >> what.Trans_type;

	if(what.Trans_type == 'D')
		IS >> what.Cust_ID;

	else
		IS >> what.Cust_ID >> what.LName >> what.FName >> what.Balance >> what.Credit_limit >> what.Status;

	return IS;
}

ostream& operator << (ostream& OS, cust_record what)
{
	if(what.Trans_type == 'D')
		OS << what.Trans_type << setw(10) << what.Cust_ID;

	else
		OS << what.Cust_ID << setw(10) << what.LName << setw(10) << what.FName << setw(10) << what.Balance << setw(10) << what.Credit_limit << setw(10) << what.Status;

	return OS;
}

istream& operator >> (istream& IS, master_record& what)
{
	IS >> what.Cust_ID >> what.LName >> what.FName >> what.Balance >> what.Credit_limit >> what.Status;

	return IS;
}

ostream& operator << (ostream& OS, master_record what)
{
	OS << what.Cust_ID << setw(10) << what.LName << setw(10) << what.FName << setw(10) << what.Balance << setw(10) << what.Credit_limit << setw(10) << what.Status;

	return OS;
}

master_record edit_master( cust_record struct1, master_record& struct2)
{
	if(struct1.Status != 'z')
		struct2.Status = struct1.Status;

	if(struct2.Status != 'H')
		if(struct1.Balance <= (struct2.Balance/2))
			struct2.Status ='O';

	if(struct1.LName != "zzz")
		struct2.LName = struct1.LName;

	if(struct1.FName != "zzz")
		struct2.FName = struct1.FName;

	if(struct1.Balance != -9999)
		struct2.Balance = struct1.Balance;

	if(struct1.Credit_limit != -9999)
		struct2.Credit_limit = struct1.Credit_limit;

	return struct2;
}

void swap(cust_record data[], int i, int j)
{
	cust_record temp;
	temp = data[i];
	data[i] = data[j];
	data[j] = temp;
}

void sort(cust_record data[],int size)
{
	for(int m=0; m<size-1; m++)
		for(int n=0; n<(size-1)-m; n++)
			if(data[n].Cust_ID > data[n+1].Cust_ID)
				swap(data, n, n+1);
}

void SortTransactionFile()
{
	int i = 0;
	cust_record data[100];
	ifstream transaction;
	transaction.open("transaction.txt");
	ofstream error_log;
	error_log.open("error_log.txt");

	while(!transaction.eof())
	{
		transaction >> data[i];
		i++;
	}
	i--;
	transaction.close();
	sort(data, i);
	ofstream Transaction;
	Transaction.open("transaction.txt");

	for(int a = 0; a < i; a++)
	{
		if(cust_ID_validator(data[a].Cust_ID))
		{
			if((data[a].Trans_type == 'A')||(data[a].Trans_type == 'E'))
				Transaction << data[a].Trans_type << "\t" << data[a] << endl;

			else
				Transaction << data[a] << endl;
		}

		else
		{
			if((data[a].Trans_type == 'A')||(data[a].Trans_type == 'E'))
				Transaction << data[a].Trans_type << "\t" << data[a] << endl;

			else if(data[a].Trans_type == 'D')
				Transaction << data[a] << endl;

			else
			{
				if((data[a].Trans_type == 'A')||(data[a].Trans_type == 'E'))
					error_log << data[a].Trans_type << "\t" << data[a] << ":\tCustomer ID invalid" << endl;

				else if(data[a].Trans_type == 'D')
					error_log << data[a] << ":\tCustomer ID invalid" << endl;
			}
		}
	}
	Transaction.close();
	error_log.close();
	return ;
}

int main();
Topic archived. No new replies allowed.