I have written a function that checks the first four characters in an
address are valid; i.e. 1d2 sour st would prove to be invalid.
bool checkdigitsinad dress( const char* string )
{
for( int i =0; i<=1; i++ )
if( !isdigit( string[i] )){}
return false;
for(i=1; i<=2; i++)
if( string[i] != isalpha(string[i]) || string[i] !=
isdigit(string[i])){}
return false;
for(i= 1; i<=2; i++)
if( string[i] == isalpha(string[i])){}
for(i= 2; i <=3; i++)
if(string[i] != isalpha(string[i])){}
return false;
for(i= 1; i<=2; i++)
if( string[i] == isdigit(string[i])){}
for(i= 2; i <=3; i++)
if(string[i] != isalpha(string[i]) || string[i] !=
isdigit(string[i])){}
return false;
for( i= 2; i<=3; i++)
if( string[i] == isalpha(string[i])){}
for(i= 3; i<=4; i++)
if(string[i] != isalpha(string[i]))
return false;
for(i =2; i<=3; i++)
for(i= 3; i<=4; i++)
if(string[i] != isalpha(string[i]) || string[i] !=
isdigit(string[i])){}
return false;
for(i= 3; i<=4; i++)
if(string[i] == isalpha(string[i])){}
for(i=4; i<=5; i++)
if(string[i] != isalpha(string[i])){}
return false;
for(i= 5; i< 25; i++)
if(string[i] != isalpha(string[i]) && string[i] != ';')
return false;
return true;
}
const char* string, is globally declared. const char* string
=&Newcrecord.cu stomeraddress[0];
bool Processcrecord( ofstream& prnfile, ofstream& validdata, char*
record )
{
strncpy( Newcrecord.cust omeraddress, &record[27], 60 );
Newcrecord.cust omeraddress[61] = '\0';
Newcrecord.cust omeraddress[61] = atol(Newcrecord .customeraddres s);
if( !checkdigitsina ddress( Newcrecord.cust omeraddress )){
prnfile<<"Inval id: incorrect format for customer address, address
must begin with numerical format:\n";
prnfile<< record <<endl;
}
return false;
there are entries and validdata is used, but none of thaat is causing
the problem. Record is the string of a file save on disk.
the line I'm reading from is:
c23454stevenlaw 12sceptrerd;Ilf ord;Essex;IG39B y;
00000.025160000 0
the address as you can see starts with a numerical entry but i still
get this return as false when I run the program. Any ideas on why that
is?
Thank you for your support.
address are valid; i.e. 1d2 sour st would prove to be invalid.
bool checkdigitsinad dress( const char* string )
{
for( int i =0; i<=1; i++ )
if( !isdigit( string[i] )){}
return false;
for(i=1; i<=2; i++)
if( string[i] != isalpha(string[i]) || string[i] !=
isdigit(string[i])){}
return false;
for(i= 1; i<=2; i++)
if( string[i] == isalpha(string[i])){}
for(i= 2; i <=3; i++)
if(string[i] != isalpha(string[i])){}
return false;
for(i= 1; i<=2; i++)
if( string[i] == isdigit(string[i])){}
for(i= 2; i <=3; i++)
if(string[i] != isalpha(string[i]) || string[i] !=
isdigit(string[i])){}
return false;
for( i= 2; i<=3; i++)
if( string[i] == isalpha(string[i])){}
for(i= 3; i<=4; i++)
if(string[i] != isalpha(string[i]))
return false;
for(i =2; i<=3; i++)
for(i= 3; i<=4; i++)
if(string[i] != isalpha(string[i]) || string[i] !=
isdigit(string[i])){}
return false;
for(i= 3; i<=4; i++)
if(string[i] == isalpha(string[i])){}
for(i=4; i<=5; i++)
if(string[i] != isalpha(string[i])){}
return false;
for(i= 5; i< 25; i++)
if(string[i] != isalpha(string[i]) && string[i] != ';')
return false;
return true;
}
const char* string, is globally declared. const char* string
=&Newcrecord.cu stomeraddress[0];
bool Processcrecord( ofstream& prnfile, ofstream& validdata, char*
record )
{
strncpy( Newcrecord.cust omeraddress, &record[27], 60 );
Newcrecord.cust omeraddress[61] = '\0';
Newcrecord.cust omeraddress[61] = atol(Newcrecord .customeraddres s);
if( !checkdigitsina ddress( Newcrecord.cust omeraddress )){
prnfile<<"Inval id: incorrect format for customer address, address
must begin with numerical format:\n";
prnfile<< record <<endl;
}
return false;
there are entries and validdata is used, but none of thaat is causing
the problem. Record is the string of a file save on disk.
the line I'm reading from is:
c23454stevenlaw 12sceptrerd;Ilf ord;Essex;IG39B y;
00000.025160000 0
the address as you can see starts with a numerical entry but i still
get this return as false when I run the program. Any ideas on why that
is?
Thank you for your support.
Comment