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.par tnum? Shouldn't Newirrecord.par tnum contain something
at run time?
Thank you in advance for your help.
bool CheckDigit(ofst ream& 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.par tnum[6] = atol( partnum );
weightingfactor = 6;
weightitem1 = (Newirrecord.pa rtnum[1] * weightingfactor );
weightingfactor = 5;
weightitem2 = (Newirrecord.pa rtnum[2] * weightingfactor );
weightingfactor = 4;
weightitem3 = (Newirrecord.pa rtnum[3] * weightingfactor );
weightingfactor = 3;
weightitem4 = (Newirrecord.pa rtnum[4] * weightingfactor );
weightingfactor = 2;
weightitem5 = (Newirrecord.pa rtnum[5] * weightingfactor );
product = (weightitem1 + weightitem2 + weightitem3 + weightitem4 +
weightitem5);
remainder = (product % Mod11);
checkdigit = (Mod11 - remainder);
if(! Newirrecord.par tnum[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.par tnum? Shouldn't Newirrecord.par tnum contain something
at run time?
Thank you in advance for your help.
bool CheckDigit(ofst ream& 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.par tnum[6] = atol( partnum );
weightingfactor = 6;
weightitem1 = (Newirrecord.pa rtnum[1] * weightingfactor );
weightingfactor = 5;
weightitem2 = (Newirrecord.pa rtnum[2] * weightingfactor );
weightingfactor = 4;
weightitem3 = (Newirrecord.pa rtnum[3] * weightingfactor );
weightingfactor = 3;
weightitem4 = (Newirrecord.pa rtnum[4] * weightingfactor );
weightingfactor = 2;
weightitem5 = (Newirrecord.pa rtnum[5] * weightingfactor );
product = (weightitem1 + weightitem2 + weightitem3 + weightitem4 +
weightitem5);
remainder = (product % Mod11);
checkdigit = (Mod11 - remainder);
if(! Newirrecord.par tnum[6] == checkdigit){
prnfile<< "Invalid part number";
prnfile<< record << endl;
}
return false;
return true;
}
Comment