M
muser
Can anyone run this program through their compiler or if they can see
a logical error please point it out. I have my tutor working on it at
the moment but I would rather a less ambigious response than the one I
think he will provide.
The test data, A:\\"514650.txt", appears at the end of the program.
The problem is that the program won't read this file and the debugger
as far as i know how to work it won't point out the mistake of any.
Can anyone also give me a step by step guide to running the debugger
also. I know that you have to put a point in main and then step
through it, but how do I get the debugger to tell me if there is a
possible error within main.
Thank you in advance.
Can anyone tell me the syntax for tellg also. Thank you.
The program:
#include<iostream.h>
#include<iomanip.h>
#include<fstream.h>
#include<string.h>
#include<stdlib.h>
#include<ctype.h>
const char filename1[] = "A:\\514650TD.txt";
const char filename2[] = "514650VD.DAT";
const int max = 104;
char alphabet[27] = "abcdefghijklmnopqrstuvwxyz";
char numbers[10] = "123456789";
char semicolon[5] = ";;;;";
int max_len = 16;
char space[18] = " ";
char i;
char c;
char r;
char d;
char temp_customer_code[5];
char temp_balance[5];
char temp_credit_limit[5];
char temp_partnum[5];
char temp_issue[5];
char temp_customer_code1[5];
char temp_customer_code2[5];
char value;
char vowels[6];
struct file1 {
char record_type;
char customer_name[20];
long customer_code[5];
char customer_address[60];
long customer_balance[9];
long credit_limit[7];
}c_record;
struct file2 {
char record_type;
long customer_code[5];
long part_num[6];
long issue_rec[4];
};
struct file3 {
char record_type;
long customer_code[5];
};
struct sum {
int calculation[5];
int calc[6];
int weight_factor[5];
};
int verify(struct file1, int abacus);//function prototype
char temp1[104], *temp_ptr = temp1;
struct file1 rec;
struct file2 rec1;
struct file3 rec2;
struct sum check;
int result;
int remainder;
int mod = 11;
int check_digit;
int count;
int reclen = 103;
int rec1len = 16;
int rec2len = 7;
bool
ok = true;
bool
error = false;
int main()
{
fstream infile;
fstream outfile;
fstream prnfile;
int index;
int count;
int passes = 200;
char *temp_ptr = new char[max];
rec.record_type = c;
rec.record_type = toupper(rec.record_type);
rec1.record_type = i;
rec1.record_type = toupper(rec1.record_type);
rec1.record_type = r;
rec1.record_type = toupper(rec1.record_type);
rec2.record_type = d;
rec2.record_type = toupper(rec2.record_type);
alphabet[27] = toupper(alphabet[27]);
vowels[6] = toupper(vowels[6]);
union records {
struct file1 rec;
struct file2 rec1;
struct file3 rec2;
struct sum check;
};
union records files;
union records *str_ptr =&files;
infile.open("A:\\514650TD.txt", ios::in);
if(infile.fail())
{
cout<<"The file does not already exist";
exit(1);
}
else
{
cout<<"514650TD is open";
};
outfile.open(filename2, ios:ut || ios::binary);
if(!outfile.is_open())
{
cout<<" The file could not be opened "<<endl;;
exit(1);
}
else
{
cout<<" 514650VD is open "<<endl;
};
prnfile.open("lpt1", ios:ut || ios::binary);
if(!prnfile.is_open())
{
cout<< "File could not be opened";
exit(1);
};
prnfile << cout<< "C_RECORD, I-R RECORD, D_RECORD ERRORS" << endl;
while(infile.peek() != EOF)
{
if(temp1[1] == rec.record_type)
{
reclen = strlen(temp1);
cout<< "c record is"
<< strlen(temp1) <<endl;
if(reclen <=103)
{
prnfile<< "Invalid c record does not contain enough characters"
<<temp1[104]<< endl;
};
};
if(temp1[1] == rec1.record_type)
{
rec1len = strlen(temp1);
cout<< "i record is"
<< strlen(temp1) <<endl;
if(rec1len <=16)
{
prnfile<< "Invalid i record does not contain enough characters"
<<temp1[104]<< endl;
};
};
if(temp1[1] == rec1.record_type)
{
rec1len = strlen(temp1);
cout<< "r record is"
<< strlen(temp1) <<endl;
if(rec1len <=16)
{
prnfile<< "Invalid r record does not contain enough characters"
<<temp1[104]<< endl;
};
};
if(temp1[1] == rec2.record_type)
{
rec2len = strlen(temp1);
cout<< "d record is"
<< strlen(temp1) << endl;
if(rec2len <=7)
{
prnfile<< "Invalid d record does not contain enough characters"
<<temp1[104]<< endl;
};
};
strncpy (files.rec.customer_name, &temp1[27], 20);
files.rec.customer_name[20] = '\0';
strncpy (temp_customer_code, &temp1[2], 5);
files.rec.customer_code[5] = '\0';
files.rec.customer_code[5] = atol(temp_customer_code);
strncpy (files.rec.customer_address, &temp1[27], 60);
files.rec.customer_address[60] = '\0';
strncpy (temp_balance, &temp1[87], 9);
files.rec.customer_balance[9] = '\0';
strncpy (temp_credit_limit, &temp1[96], 7);
files.rec.credit_limit[7] = '\0';
files.rec.credit_limit[7] = atol(temp_credit_limit);
strncpy(temp_customer_code1, &temp1[2], 5);
files.rec1.customer_code[5] = '\0';
files.rec1.customer_code[5] = atol(temp_customer_code1);
strncpy(temp_partnum, &temp1[7], 6);
files.rec1.part_num[6] = '\0';
files.rec1.part_num[6] = atol(temp_partnum);
strncpy(temp_issue, &temp1[13], 4);
files.rec1.issue_rec[4] = '\0';
files.rec1.issue_rec[4] = atol(temp_issue);
strncpy(temp_customer_code2, &temp1[2], 5);
files.rec2.customer_code[5] = '\0';
files.rec2.customer_code[5] = atol(temp_customer_code2);
if(temp1[1] != files.rec.record_type || files.rec1.record_type ||
files.rec2.record_type)
{
ok = false;
error = true;
prnfile << "Error files";
prnfile << temp1[104] <<endl;
}
else
if(temp1[1] == files.rec.record_type || files.rec1.record_type ||
files.rec2.record_type)
{
ok = true;
error = false;
cout<< "valid record type" <<endl;
outfile.write((&value), sizeof(files.rec.record_type));
outfile.write((&value), sizeof(files.rec1.record_type));
outfile.write((&value), sizeof(files.rec2.record_type));
};
count = 0;
temp_ptr = temp1;
cin.getline(temp_ptr, max);
if(temp1[2] = numbers[10])
{
do{
for(index = 0; index < temp1[6]; index++)
rec.customer_code[5] = temp1[index];
}
while(count < passes);
count++;
}
else
if(files.rec.customer_code[5] != numbers[10])
{
prnfile<< "customer code invalid code, code contains a non digit
charater" << endl;
};
check.calculation[5] =
(sizeof(check.calculation)/sizeof(check.calculation[0]));
for(count = 0; count < 5; count++)
{
check.calculation[1] = check.weight_factor[1] * rec.customer_code[1];
check.calculation[2] = check.weight_factor[2] * rec.customer_code[2];
check.calculation[3] = check.weight_factor[3] * rec.customer_code[3];
check.calculation[4] = check.weight_factor[4] * rec.customer_code[4];
check.calculation[5] = check.weight_factor[5] * rec.customer_code[5];
};
result = (sizeof(result)/sizeof(check.calculation[0]));
while(count++)
{
result = check.calculation[1] + check.calculation[2] +
check.calculation[3] + check.calculation[4] + check.calculation[5];
};
remainder = result % mod;
check_digit = mod - remainder;
if(check_digit + remainder == mod)
{
ok = true;
error = false;
}
else
{
ok = false;
error = true;
};
if(ok = true)
{
outfile.write((&value), sizeof(files.rec.customer_code));
};
//count must be correct from its state in the infinite loop.
if(temp1[7] = alphabet[24])
{
count = 0;
do{
for(index = 0; index < temp1[27]; index++)
rec.customer_name[20] = temp1[index];
}
while(count < passes);
count++;
}
else
{
prnfile<< "Invalid customer name, is not in an aphabetical format"
<< temp1[104] << endl;
};
if(temp1[1] == files.rec.record_type && temp1[27] == alphabet[24])
{
count = 0;
do{
for(index = 0; index < temp1[86]; index++);
rec.customer_address[60] = temp1[index];
int verify(struct file1, int abacus);
count++;
}
while(count < passes);
}
else
if(files.rec.customer_address[60] != alphabet[24] &&
files.rec.customer_address[60] != numbers[10])
{
if(files.rec.customer_address[60] > space[18] ||
files.rec.customer_address[60] != semicolon[5])
{
prnfile<< "Invalid customer address"
<< "incorrect address format"
<<temp1[104] <<endl;
};
};
if(temp1[1] == files.rec.record_type && temp1[87] == numbers[10])
{
count = 0;
do{
for(index =0; index < temp1[95]; index++)
files.rec.customer_balance[9] = temp1[index];
count++;
}
while(count < passes);
}
else
if(files.rec.customer_balance[9] != numbers[10])
{
ok = false;
error = true;
prnfile<<"Invalid customer balance, does not contain numerical
format"
<<temp1[104] <<endl;
};
if(files.rec.customer_balance[9] = numbers[10])
{
ok = true;
error = false;
outfile.write((&value), sizeof(files.rec.customer_balance));
};
if(temp1[1] == files.rec.record_type && temp1[96] == numbers[10])
{
count = 0;
do{
for(index =0; index < temp1[102]; index++)
files.rec.credit_limit[7] = temp1[index];
}
while(count < passes);
count++;
}
else
if(files.rec.credit_limit[7] != numbers[10])
{
cout<<"Invalid credit limit, does not contain numerical
format"<<endl;
};
if(files.rec.credit_limit[7] = numbers[10])
{
ok = true;
error = false;
outfile.write((&value), sizeof(files.rec.credit_limit));
};
if(temp1[1] = files.rec1.record_type)// needs check digit 11
formulae.
{
do{
count = 0;
for(index = 1; index < temp1[6]; index++);
files.rec1.customer_code[5] = temp1[index];
}
while(count < passes);
count++;
}
else
if(files.rec1.customer_code[5] != numbers[10])
{
prnfile<< "customer code invalid code, code contains a non digit
charater"
<<temp1[16]<< endl;
};
if(files.rec1.customer_code[5] = numbers[10])
{
ok = true;
error = false;
outfile.write((&value), sizeof(files.rec1.customer_code));
};
if(temp1[1] = files.rec1.record_type)//need check digit 11 formulae.
{
do{
for(index =7; index < temp1[12]; index++)
files.rec1.part_num[5] = temp1[index];
}
while(count < passes);
count++;
}
else
if(files.rec1.part_num[5] != numbers[10])
{
prnfile<< "customer code invalid code, code contains a non digit
charater"
<<temp1[16]<< endl;
};
if(files.rec1.part_num[5] = numbers[10])
{
ok = true;
error = false;
outfile.write((&value), sizeof(files.rec1.part_num));
};
// if check digit ok then do.
check.calculation[5] =
(sizeof(check.calculation)/sizeof(check.calculation[0]));
for(count = 0; count < 5; count++)
{
check.calculation[1] = check.weight_factor[1] *
files.rec1.customer_code[1];
check.calculation[2] = check.weight_factor[2] *
files.rec1.customer_code[2];
check.calculation[3] = check.weight_factor[3] *
files.rec1.customer_code[3];
check.calculation[4] = check.weight_factor[4] *
files.rec1.customer_code[4];
check.calculation[5] = check.weight_factor[5] *
files.rec1.customer_code[5];
};
result = (sizeof(result)/sizeof(check.calculation[0]));
while(count++)
{
result = check.calculation[1] + check.calculation[2] +
check.calculation[3] + check.calculation[4] + check.calculation[5];
};
remainder = result % mod;
check_digit = mod - remainder;
if(check_digit + remainder == mod)
{
ok = true;
error = false;
}
else
{
ok = false;
error = true;
};
if(ok = true)
{
outfile.write((&value), sizeof(files.rec1.customer_code));
};
check.calculation[5] =
(sizeof(check.calculation)/sizeof(check.calculation[0]));
for(count = 0; count < 5; count++)
{
check.calculation[1] = check.weight_factor[1] *
files.rec1.part_num[1];
check.calculation[2] = check.weight_factor[2] *
files.rec1.part_num[2];
check.calculation[3] = check.weight_factor[3] *
files.rec1.part_num[3];
check.calculation[4] = check.weight_factor[4] *
files.rec1.part_num[4];
check.calculation[5] = check.weight_factor[5] *
files.rec1.part_num[5];
check.calculation[6] = check.weight_factor[6] *
files.rec1.part_num[6];
};
result = (sizeof(result)/sizeof(check.calculation[0]));
while(count++)
{
result = check.calculation[1] + check.calculation[2] +
check.calculation[3] + check.calculation[4] + check.calculation[5];
};
remainder = result % mod;
check_digit = mod - remainder;
if(check_digit + remainder == mod)
{
ok = true;
error = false;
}
else
{
ok = false;
error = true;
};
if(ok = true)
{
outfile.write((&value), sizeof(files.rec1.part_num));
};///////////////////////////
if(temp1[1] = files.rec2.record_type)
{
if(temp1[2] = numbers[10])
{
do{
for(index = 0; index < temp1[6]; index++)
files.rec2.customer_code[5] = temp1[index];
}
while(count < passes);
count++;
}
else
if(files.rec2.customer_code[5] != numbers[10])
{
prnfile<< "customer code invalid code, code contains a non digit
charater" << endl;
};
};
};
infile.close();
outfile.close();
prnfile.close();
return 0;
};
int verify(struct file1, int abacus, char semi_colons[2] = ";")
{
fstream prnfile;
fstream infile;
fstream outfile;
int vowel_check = 0;
int word = 0;
const int max_word = 16;
const int vowel_average = 2;
if(rec.customer_address[60] = vowels[6])
{
do{
for(temp_ptr[max]; &rec.customer_address[1];
for(temp_ptr[max] = rec.customer_address[1]; temp_ptr++;
temp_ptr = '\0';
if(temp_ptr[max] = semi_colons[2])
{
word++;
};
for(temp_ptr++; abacus++;
if(word >=1)
{
cout<<"word length is"<< abacus <<endl;
if(abacus > max_word)
{
prnfile<< "CUSTOMER ADDRESS ERRORS"
<< "Word is invalid. Entry contains too many characters"
<< temp1[104] <<endl;
}
else
if(abacus <= max_word)
{
cout<< "First check completed for customer address"<< endl;
};
};
if(temp_ptr[max] = vowels[6])
{
vowel_check++;
}
else
if(temp_ptr[max] != vowels[6])
{
prnfile<< "CUSTOMER ADDRESS ERRORS"
<< "Invalid customer address"
<< temp1[104] << endl;
};
if(vowel_check >= vowel_average)
{
ok = true;
error = false;
outfile.write((&value), sizeof(rec.customer_address));
};
}
while(infile.eof());
};
return ok;c 98581 tod terry
312;Dawlish;Drive;Ilford;Essex;IG3;9ED; 000000.25
00000.100
c 45238 kelvin patrick
21;castleton;drive;Ilford;Essex;IG3;2DQ; 00000.076 0000.1600
i 23759 856343 9685
d 54789
d 35498
i 49586 412562 3759
c 26424 sean o'connor 567;ley;street;leytonstone;Essex;W15;
000000.24 0000.2000
};
The test data:
a logical error please point it out. I have my tutor working on it at
the moment but I would rather a less ambigious response than the one I
think he will provide.
The test data, A:\\"514650.txt", appears at the end of the program.
The problem is that the program won't read this file and the debugger
as far as i know how to work it won't point out the mistake of any.
Can anyone also give me a step by step guide to running the debugger
also. I know that you have to put a point in main and then step
through it, but how do I get the debugger to tell me if there is a
possible error within main.
Thank you in advance.
Can anyone tell me the syntax for tellg also. Thank you.
The program:
#include<iostream.h>
#include<iomanip.h>
#include<fstream.h>
#include<string.h>
#include<stdlib.h>
#include<ctype.h>
const char filename1[] = "A:\\514650TD.txt";
const char filename2[] = "514650VD.DAT";
const int max = 104;
char alphabet[27] = "abcdefghijklmnopqrstuvwxyz";
char numbers[10] = "123456789";
char semicolon[5] = ";;;;";
int max_len = 16;
char space[18] = " ";
char i;
char c;
char r;
char d;
char temp_customer_code[5];
char temp_balance[5];
char temp_credit_limit[5];
char temp_partnum[5];
char temp_issue[5];
char temp_customer_code1[5];
char temp_customer_code2[5];
char value;
char vowels[6];
struct file1 {
char record_type;
char customer_name[20];
long customer_code[5];
char customer_address[60];
long customer_balance[9];
long credit_limit[7];
}c_record;
struct file2 {
char record_type;
long customer_code[5];
long part_num[6];
long issue_rec[4];
};
struct file3 {
char record_type;
long customer_code[5];
};
struct sum {
int calculation[5];
int calc[6];
int weight_factor[5];
};
int verify(struct file1, int abacus);//function prototype
char temp1[104], *temp_ptr = temp1;
struct file1 rec;
struct file2 rec1;
struct file3 rec2;
struct sum check;
int result;
int remainder;
int mod = 11;
int check_digit;
int count;
int reclen = 103;
int rec1len = 16;
int rec2len = 7;
bool
ok = true;
bool
error = false;
int main()
{
fstream infile;
fstream outfile;
fstream prnfile;
int index;
int count;
int passes = 200;
char *temp_ptr = new char[max];
rec.record_type = c;
rec.record_type = toupper(rec.record_type);
rec1.record_type = i;
rec1.record_type = toupper(rec1.record_type);
rec1.record_type = r;
rec1.record_type = toupper(rec1.record_type);
rec2.record_type = d;
rec2.record_type = toupper(rec2.record_type);
alphabet[27] = toupper(alphabet[27]);
vowels[6] = toupper(vowels[6]);
union records {
struct file1 rec;
struct file2 rec1;
struct file3 rec2;
struct sum check;
};
union records files;
union records *str_ptr =&files;
infile.open("A:\\514650TD.txt", ios::in);
if(infile.fail())
{
cout<<"The file does not already exist";
exit(1);
}
else
{
cout<<"514650TD is open";
};
outfile.open(filename2, ios:ut || ios::binary);
if(!outfile.is_open())
{
cout<<" The file could not be opened "<<endl;;
exit(1);
}
else
{
cout<<" 514650VD is open "<<endl;
};
prnfile.open("lpt1", ios:ut || ios::binary);
if(!prnfile.is_open())
{
cout<< "File could not be opened";
exit(1);
};
prnfile << cout<< "C_RECORD, I-R RECORD, D_RECORD ERRORS" << endl;
while(infile.peek() != EOF)
{
if(temp1[1] == rec.record_type)
{
reclen = strlen(temp1);
cout<< "c record is"
<< strlen(temp1) <<endl;
if(reclen <=103)
{
prnfile<< "Invalid c record does not contain enough characters"
<<temp1[104]<< endl;
};
};
if(temp1[1] == rec1.record_type)
{
rec1len = strlen(temp1);
cout<< "i record is"
<< strlen(temp1) <<endl;
if(rec1len <=16)
{
prnfile<< "Invalid i record does not contain enough characters"
<<temp1[104]<< endl;
};
};
if(temp1[1] == rec1.record_type)
{
rec1len = strlen(temp1);
cout<< "r record is"
<< strlen(temp1) <<endl;
if(rec1len <=16)
{
prnfile<< "Invalid r record does not contain enough characters"
<<temp1[104]<< endl;
};
};
if(temp1[1] == rec2.record_type)
{
rec2len = strlen(temp1);
cout<< "d record is"
<< strlen(temp1) << endl;
if(rec2len <=7)
{
prnfile<< "Invalid d record does not contain enough characters"
<<temp1[104]<< endl;
};
};
strncpy (files.rec.customer_name, &temp1[27], 20);
files.rec.customer_name[20] = '\0';
strncpy (temp_customer_code, &temp1[2], 5);
files.rec.customer_code[5] = '\0';
files.rec.customer_code[5] = atol(temp_customer_code);
strncpy (files.rec.customer_address, &temp1[27], 60);
files.rec.customer_address[60] = '\0';
strncpy (temp_balance, &temp1[87], 9);
files.rec.customer_balance[9] = '\0';
strncpy (temp_credit_limit, &temp1[96], 7);
files.rec.credit_limit[7] = '\0';
files.rec.credit_limit[7] = atol(temp_credit_limit);
strncpy(temp_customer_code1, &temp1[2], 5);
files.rec1.customer_code[5] = '\0';
files.rec1.customer_code[5] = atol(temp_customer_code1);
strncpy(temp_partnum, &temp1[7], 6);
files.rec1.part_num[6] = '\0';
files.rec1.part_num[6] = atol(temp_partnum);
strncpy(temp_issue, &temp1[13], 4);
files.rec1.issue_rec[4] = '\0';
files.rec1.issue_rec[4] = atol(temp_issue);
strncpy(temp_customer_code2, &temp1[2], 5);
files.rec2.customer_code[5] = '\0';
files.rec2.customer_code[5] = atol(temp_customer_code2);
if(temp1[1] != files.rec.record_type || files.rec1.record_type ||
files.rec2.record_type)
{
ok = false;
error = true;
prnfile << "Error files";
prnfile << temp1[104] <<endl;
}
else
if(temp1[1] == files.rec.record_type || files.rec1.record_type ||
files.rec2.record_type)
{
ok = true;
error = false;
cout<< "valid record type" <<endl;
outfile.write((&value), sizeof(files.rec.record_type));
outfile.write((&value), sizeof(files.rec1.record_type));
outfile.write((&value), sizeof(files.rec2.record_type));
};
count = 0;
temp_ptr = temp1;
cin.getline(temp_ptr, max);
if(temp1[2] = numbers[10])
{
do{
for(index = 0; index < temp1[6]; index++)
rec.customer_code[5] = temp1[index];
}
while(count < passes);
count++;
}
else
if(files.rec.customer_code[5] != numbers[10])
{
prnfile<< "customer code invalid code, code contains a non digit
charater" << endl;
};
check.calculation[5] =
(sizeof(check.calculation)/sizeof(check.calculation[0]));
for(count = 0; count < 5; count++)
{
check.calculation[1] = check.weight_factor[1] * rec.customer_code[1];
check.calculation[2] = check.weight_factor[2] * rec.customer_code[2];
check.calculation[3] = check.weight_factor[3] * rec.customer_code[3];
check.calculation[4] = check.weight_factor[4] * rec.customer_code[4];
check.calculation[5] = check.weight_factor[5] * rec.customer_code[5];
};
result = (sizeof(result)/sizeof(check.calculation[0]));
while(count++)
{
result = check.calculation[1] + check.calculation[2] +
check.calculation[3] + check.calculation[4] + check.calculation[5];
};
remainder = result % mod;
check_digit = mod - remainder;
if(check_digit + remainder == mod)
{
ok = true;
error = false;
}
else
{
ok = false;
error = true;
};
if(ok = true)
{
outfile.write((&value), sizeof(files.rec.customer_code));
};
//count must be correct from its state in the infinite loop.
if(temp1[7] = alphabet[24])
{
count = 0;
do{
for(index = 0; index < temp1[27]; index++)
rec.customer_name[20] = temp1[index];
}
while(count < passes);
count++;
}
else
{
prnfile<< "Invalid customer name, is not in an aphabetical format"
<< temp1[104] << endl;
};
if(temp1[1] == files.rec.record_type && temp1[27] == alphabet[24])
{
count = 0;
do{
for(index = 0; index < temp1[86]; index++);
rec.customer_address[60] = temp1[index];
int verify(struct file1, int abacus);
count++;
}
while(count < passes);
}
else
if(files.rec.customer_address[60] != alphabet[24] &&
files.rec.customer_address[60] != numbers[10])
{
if(files.rec.customer_address[60] > space[18] ||
files.rec.customer_address[60] != semicolon[5])
{
prnfile<< "Invalid customer address"
<< "incorrect address format"
<<temp1[104] <<endl;
};
};
if(temp1[1] == files.rec.record_type && temp1[87] == numbers[10])
{
count = 0;
do{
for(index =0; index < temp1[95]; index++)
files.rec.customer_balance[9] = temp1[index];
count++;
}
while(count < passes);
}
else
if(files.rec.customer_balance[9] != numbers[10])
{
ok = false;
error = true;
prnfile<<"Invalid customer balance, does not contain numerical
format"
<<temp1[104] <<endl;
};
if(files.rec.customer_balance[9] = numbers[10])
{
ok = true;
error = false;
outfile.write((&value), sizeof(files.rec.customer_balance));
};
if(temp1[1] == files.rec.record_type && temp1[96] == numbers[10])
{
count = 0;
do{
for(index =0; index < temp1[102]; index++)
files.rec.credit_limit[7] = temp1[index];
}
while(count < passes);
count++;
}
else
if(files.rec.credit_limit[7] != numbers[10])
{
cout<<"Invalid credit limit, does not contain numerical
format"<<endl;
};
if(files.rec.credit_limit[7] = numbers[10])
{
ok = true;
error = false;
outfile.write((&value), sizeof(files.rec.credit_limit));
};
if(temp1[1] = files.rec1.record_type)// needs check digit 11
formulae.
{
do{
count = 0;
for(index = 1; index < temp1[6]; index++);
files.rec1.customer_code[5] = temp1[index];
}
while(count < passes);
count++;
}
else
if(files.rec1.customer_code[5] != numbers[10])
{
prnfile<< "customer code invalid code, code contains a non digit
charater"
<<temp1[16]<< endl;
};
if(files.rec1.customer_code[5] = numbers[10])
{
ok = true;
error = false;
outfile.write((&value), sizeof(files.rec1.customer_code));
};
if(temp1[1] = files.rec1.record_type)//need check digit 11 formulae.
{
do{
for(index =7; index < temp1[12]; index++)
files.rec1.part_num[5] = temp1[index];
}
while(count < passes);
count++;
}
else
if(files.rec1.part_num[5] != numbers[10])
{
prnfile<< "customer code invalid code, code contains a non digit
charater"
<<temp1[16]<< endl;
};
if(files.rec1.part_num[5] = numbers[10])
{
ok = true;
error = false;
outfile.write((&value), sizeof(files.rec1.part_num));
};
// if check digit ok then do.
check.calculation[5] =
(sizeof(check.calculation)/sizeof(check.calculation[0]));
for(count = 0; count < 5; count++)
{
check.calculation[1] = check.weight_factor[1] *
files.rec1.customer_code[1];
check.calculation[2] = check.weight_factor[2] *
files.rec1.customer_code[2];
check.calculation[3] = check.weight_factor[3] *
files.rec1.customer_code[3];
check.calculation[4] = check.weight_factor[4] *
files.rec1.customer_code[4];
check.calculation[5] = check.weight_factor[5] *
files.rec1.customer_code[5];
};
result = (sizeof(result)/sizeof(check.calculation[0]));
while(count++)
{
result = check.calculation[1] + check.calculation[2] +
check.calculation[3] + check.calculation[4] + check.calculation[5];
};
remainder = result % mod;
check_digit = mod - remainder;
if(check_digit + remainder == mod)
{
ok = true;
error = false;
}
else
{
ok = false;
error = true;
};
if(ok = true)
{
outfile.write((&value), sizeof(files.rec1.customer_code));
};
check.calculation[5] =
(sizeof(check.calculation)/sizeof(check.calculation[0]));
for(count = 0; count < 5; count++)
{
check.calculation[1] = check.weight_factor[1] *
files.rec1.part_num[1];
check.calculation[2] = check.weight_factor[2] *
files.rec1.part_num[2];
check.calculation[3] = check.weight_factor[3] *
files.rec1.part_num[3];
check.calculation[4] = check.weight_factor[4] *
files.rec1.part_num[4];
check.calculation[5] = check.weight_factor[5] *
files.rec1.part_num[5];
check.calculation[6] = check.weight_factor[6] *
files.rec1.part_num[6];
};
result = (sizeof(result)/sizeof(check.calculation[0]));
while(count++)
{
result = check.calculation[1] + check.calculation[2] +
check.calculation[3] + check.calculation[4] + check.calculation[5];
};
remainder = result % mod;
check_digit = mod - remainder;
if(check_digit + remainder == mod)
{
ok = true;
error = false;
}
else
{
ok = false;
error = true;
};
if(ok = true)
{
outfile.write((&value), sizeof(files.rec1.part_num));
};///////////////////////////
if(temp1[1] = files.rec2.record_type)
{
if(temp1[2] = numbers[10])
{
do{
for(index = 0; index < temp1[6]; index++)
files.rec2.customer_code[5] = temp1[index];
}
while(count < passes);
count++;
}
else
if(files.rec2.customer_code[5] != numbers[10])
{
prnfile<< "customer code invalid code, code contains a non digit
charater" << endl;
};
};
};
infile.close();
outfile.close();
prnfile.close();
return 0;
};
int verify(struct file1, int abacus, char semi_colons[2] = ";")
{
fstream prnfile;
fstream infile;
fstream outfile;
int vowel_check = 0;
int word = 0;
const int max_word = 16;
const int vowel_average = 2;
if(rec.customer_address[60] = vowels[6])
{
do{
for(temp_ptr[max]; &rec.customer_address[1];
for(temp_ptr[max] = rec.customer_address[1]; temp_ptr++;
temp_ptr = '\0';
if(temp_ptr[max] = semi_colons[2])
{
word++;
};
for(temp_ptr++; abacus++;
if(word >=1)
{
cout<<"word length is"<< abacus <<endl;
if(abacus > max_word)
{
prnfile<< "CUSTOMER ADDRESS ERRORS"
<< "Word is invalid. Entry contains too many characters"
<< temp1[104] <<endl;
}
else
if(abacus <= max_word)
{
cout<< "First check completed for customer address"<< endl;
};
};
if(temp_ptr[max] = vowels[6])
{
vowel_check++;
}
else
if(temp_ptr[max] != vowels[6])
{
prnfile<< "CUSTOMER ADDRESS ERRORS"
<< "Invalid customer address"
<< temp1[104] << endl;
};
if(vowel_check >= vowel_average)
{
ok = true;
error = false;
outfile.write((&value), sizeof(rec.customer_address));
};
}
while(infile.eof());
};
return ok;c 98581 tod terry
312;Dawlish;Drive;Ilford;Essex;IG3;9ED; 000000.25
00000.100
c 45238 kelvin patrick
21;castleton;drive;Ilford;Essex;IG3;2DQ; 00000.076 0000.1600
i 23759 856343 9685
d 54789
d 35498
i 49586 412562 3759
c 26424 sean o'connor 567;ley;street;leytonstone;Essex;W15;
000000.24 0000.2000
};
The test data: