472,779 Members | 1,987 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,779 software developers and data experts.

Logical error/ whole program contained within.

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::out || 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::out || 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:
Jul 19 '05 #1
4 3936
muser wrote:
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.


Well, I see at least one glaring logic error in your code. In many of
your if() statements, you are incorrectly performing assignment operations

a = b

when you *should* be performing value comparison operations

a == b

e.g.,

if ( a = b ) // WRONG -- this assigns b's value into a

if ( a == b ) // CORRECT -- this compares the values in a and b

--
Jim

To reply by email, remove "link" and change "now.here" to "yahoo"
jfischer_link5809{at}now.here.com
Jul 19 '05 #2
Scads of errors, suggest you get practising with the debugger. But I'll
point out a few below.

This is the first newbie lesson, a compiling program is not a debugged
program, nothing like.

"muser" <ch**********@hotmail.com> wrote in message
news:f9**************************@posting.google.c om...
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;

These above are all uninitialised varaibles (or rather zero initialised)
which is fine but ...
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];
This is wrong. That is five longs! You just want one

long customer_code;
char customer_address[60];
long customer_balance[9];
Diito

long customer_balance;
long credit_limit[7];
Ditto

long credit_limit;
}c_record;

struct file2 {
char record_type;
long customer_code[5];
long part_num[6];
long issue_rec[4];
Ditto, ditto, ditto.
};

struct file3 {
char record_type;
long customer_code[5];
Ditto.
};

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);

Here you are using the uninitalised variable above. I suspect that what you
really meant to say was

rec.record_type = 'C';

No need for the variable or for the toupper.

rec1.record_type = i;
rec1.record_type = toupper(rec1.record_type);
rec1.record_type = r;
rec1.record_type = toupper(rec1.record_type);

Ditto, and why assign i and then immediately change it to r?
rec2.record_type = d;
rec2.record_type = toupper(rec2.record_type);
Ditto.

alphabet[27] = toupper(alphabet[27]);
vowels[6] = toupper(vowels[6]);
Neither of these do what you think they do. toupper converts a *single*
character to uppercase. Also alphabet[27] and vowels[6] do not exist because
the arrays are too small. Obviously what you want to do is convert the
entrie array to upper case, but if you want that why not declare it that way
in the first place?


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::out || 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::out || 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);
temp1 is also completely uninitalised, not sure what you are trying to
acheive here, perhaps you missed out a read statement?

cout<< "c record is"
<< strlen(temp1) <<endl;

if(reclen <=103)
{
prnfile<< "Invalid c record does not contain enough characters"
<<temp1[104]<< endl;
Again this is the same mistake you made with alphabet and vowels. temp1[104]
is a *single* character, not the entire string. The way to output the entire
string is

<< temp1 << 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;
Ditto
};

};
if(temp1[1] == rec1.record_type)
Two comparisons to rec1.record_type, something mysterious going on here.
Perhaps you need rec, rec1, rec2, and rec3. Seems you are short of one
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;
Ditto.
};

};
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;
Ditto.
};
};

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);
With the correction to file1 above

files.rec.customer_code = 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);
Ditto

files.rec.credit_limit = 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);


Ditto

files.rec1.customer_code = atol(temp_customer_code1);

[snip]

I'm sure there are many many more errors. I just found the above by
eyeballing the code, I try to work out what it is actually supposed to do.

john
Jul 19 '05 #3
Sin
> 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.


A debugger doens't tell you where the bugs are... It allows you to see what
code is being executed when, and what it does to the data used by it...

There are several ways to use the debugger. Sometimes you'll have an idea of
where the program fails and you can put a breakpoint before or on that spot.
You then execute the program and it will stop at that breakpoint. You can
then inspect the data to make sure it's in a valid (or expected) state, and
then step one function at a time to see if they do as expected.

As someone mentionned, you are using the assignation (=) operator rather
than the comparison operator (==). Had you used the debugger, you would have
seen that sometimes this statement would not work as expected. If both A and
B are zero for example, the debugger would have skipped the inner if rather
than (what YOU would have expected) enter in it...

Other ways to use the debugger would be to step through all the code, not
using breakpoints. Some debuggers will also allow to install evential
breakpoints (ex: "break when A changes") which can be usefull in special
occasions.

There's another kind of debugger than goes further, they are called
profilers. These might for example watch memory allocation/deallocation for
you, memory overruns, etc. They might also tell you which code has been used
within an execution to allow you to do a full coverage of the
functionnalities of your program.

Like all things, experience is the key...

Alex.
Jul 19 '05 #4
Jim Fischer wrote:
muser wrote:
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.

Well, I see at least one glaring logic error in your code. In many of
your if() statements, you are incorrectly performing assignment operations

a = b

when you *should* be performing value comparison operations

a == b

e.g.,

if ( a = b ) // WRONG -- this assigns b's value into a

if ( a == b ) // CORRECT -- this compares the values in a and b


BTW, if your compiler emits warning messages as it translates your C/C++
program, DO NOT ignore those warnings. Warning messages identify
problems that are very real -- e.g., common logic errors that make a
program behave in unexpected / undesirable ways at run time. So DO NOT
get yourself into the mindset that you can safely ignore all warning
messages. This is folly!

BTW2, if the compiler (and/or linker) does not emit any warning/error
messages, this DOES NOT mean the program is "correct". There may still
be logic errors in your code that cause unexpected / undesirable
behaviors at run time. (This is when the debugger software comes in
handy...)

--
Jim

To reply by email, remove "link" and change "now.here" to "yahoo"
jfischer_link5809{at}now.here.com
Jul 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

67
by: Steven T. Hatton | last post by:
Some people have suggested the desire for code completion and refined edit-time error detection are an indication of incompetence on the part of the programmer who wants such features. ...
9
by: torbs | last post by:
Hi I am creating a page for stretchfilm. In this page you can chose between a short medium and long version of the film at any point in the film. It is in norwegian, but just press play. URL:...
4
by: GRoll21 | last post by:
The problem starts during my while loop. It checks to see if they hit x or X. If they did, then that means the user wants to exit. Then should go on and hit the return statement. It just quits....
6
by: Peter Frost | last post by:
Please help I don't know if this is possible but what I would really like to do is to use On Error Goto to capture the code that is being executed when an error occurs. Any help would be much...
0
by: DC | last post by:
The problem I'm using the .NET GridView and FormView objects for the first time and im getting the error "An OleDbParameter with ParameterName '@ID' is not contained by this...
9
by: marko | last post by:
/* code start */ int a = 0; /* expected evaluation and excution order with precedence in mind /* False(3) , True(1), False(2) */ if ( (a=1) == 0 || 0 != 1 && (a =2) == 1) putchar('T');...
0
by: erik.erikson | last post by:
I am getting a compiler error that I can't well explain or even understand the origin of (though I boiled it down close...). Below is a bare-bones example. What I am doing is defining the...
11
by: Bryan Crouse | last post by:
I am looking a way to do error checking on a string at compile time, and if the string isn't the correct length have then have the compiler throw an error. I am working an embedded software that...
3
blazedaces
by: blazedaces | last post by:
Hello, it's been a while since I posted on these forums. My issue I think isn't as much in my code as it's in the syntax and structure in references other packages. I'll get straight to it then: ...
0
by: Rina0 | last post by:
Cybersecurity engineering is a specialized field that focuses on the design, development, and implementation of systems, processes, and technologies that protect against cyber threats and...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.