M
muser
The following function gives me the following error: warning C4700:
local variable 'Newirrecord' used without having been initialized.
Newirrecord is the instance of a structure. I get the same in another
function as well, where an ordinary variable gives me the same
warning.
isn't strncpy passing a string to partnum which in turn I access with
Newirrecord.partnum? Shouldn't Newirrecord.partnum contain something
at run time?
Thank you in advance for your help.
bool CheckDigit(ofstream& prnfile, char* record)
{
int weightingfactor;
int remainder;
int weightitem1, weightitem2, weightitem3, weightitem4, weightitem5;
int product;
int Mod11 = 11;
int checkdigit;
char partnum[6];
irrecord Newirrecord;
strncpy(partnum, &record[7], 6);
partnum[6] = '\0';
Newirrecord.partnum[6] = atol( partnum );
weightingfactor = 6;
weightitem1 = (Newirrecord.partnum[1] * weightingfactor);
weightingfactor = 5;
weightitem2 = (Newirrecord.partnum[2] * weightingfactor);
weightingfactor = 4;
weightitem3 = (Newirrecord.partnum[3] * weightingfactor);
weightingfactor = 3;
weightitem4 = (Newirrecord.partnum[4] * weightingfactor);
weightingfactor = 2;
weightitem5 = (Newirrecord.partnum[5] * weightingfactor);
product = (weightitem1 + weightitem2 + weightitem3 + weightitem4 +
weightitem5);
remainder = (product % Mod11);
checkdigit = (Mod11 - remainder);
if(! Newirrecord.partnum[6] == checkdigit){
prnfile<< "Invalid part number";
prnfile<< record << endl;
}
return false;
return true;
}
local variable 'Newirrecord' used without having been initialized.
Newirrecord is the instance of a structure. I get the same in another
function as well, where an ordinary variable gives me the same
warning.
isn't strncpy passing a string to partnum which in turn I access with
Newirrecord.partnum? Shouldn't Newirrecord.partnum contain something
at run time?
Thank you in advance for your help.
bool CheckDigit(ofstream& prnfile, char* record)
{
int weightingfactor;
int remainder;
int weightitem1, weightitem2, weightitem3, weightitem4, weightitem5;
int product;
int Mod11 = 11;
int checkdigit;
char partnum[6];
irrecord Newirrecord;
strncpy(partnum, &record[7], 6);
partnum[6] = '\0';
Newirrecord.partnum[6] = atol( partnum );
weightingfactor = 6;
weightitem1 = (Newirrecord.partnum[1] * weightingfactor);
weightingfactor = 5;
weightitem2 = (Newirrecord.partnum[2] * weightingfactor);
weightingfactor = 4;
weightitem3 = (Newirrecord.partnum[3] * weightingfactor);
weightingfactor = 3;
weightitem4 = (Newirrecord.partnum[4] * weightingfactor);
weightingfactor = 2;
weightitem5 = (Newirrecord.partnum[5] * weightingfactor);
product = (weightitem1 + weightitem2 + weightitem3 + weightitem4 +
weightitem5);
remainder = (product % Mod11);
checkdigit = (Mod11 - remainder);
if(! Newirrecord.partnum[6] == checkdigit){
prnfile<< "Invalid part number";
prnfile<< record << endl;
}
return false;
return true;
}