M
muser
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 checkdigitsinaddress( const char* string )
{
for( int i =0; i<=1; i++ )
if( !isdigit( string )){}
return false;
for(i=1; i<=2; i++)
if( string != isalpha(string) || string !=
isdigit(string)){}
return false;
for(i= 1; i<=2; i++)
if( string == isalpha(string)){}
for(i= 2; i <=3; i++)
if(string != isalpha(string)){}
return false;
for(i= 1; i<=2; i++)
if( string == isdigit(string)){}
for(i= 2; i <=3; i++)
if(string != isalpha(string) || string !=
isdigit(string)){}
return false;
for( i= 2; i<=3; i++)
if( string == isalpha(string)){}
for(i= 3; i<=4; i++)
if(string != isalpha(string))
return false;
for(i =2; i<=3; i++)
for(i= 3; i<=4; i++)
if(string != isalpha(string) || string !=
isdigit(string)){}
return false;
for(i= 3; i<=4; i++)
if(string == isalpha(string)){}
for(i=4; i<=5; i++)
if(string != isalpha(string)){}
return false;
for(i= 5; i< 25; i++)
if(string != isalpha(string) && string != ';')
return false;
return true;
}
const char* string, is globally declared. const char* string
=&Newcrecord.customeraddress[0];
bool Processcrecord( ofstream& prnfile, ofstream& validdata, char*
record )
{
strncpy( Newcrecord.customeraddress, &record[27], 60 );
Newcrecord.customeraddress[61] = '\0';
Newcrecord.customeraddress[61] = atol(Newcrecord.customeraddress);
if( !checkdigitsinaddress( Newcrecord.customeraddress )){
prnfile<<"Invalid: 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;Ilford;Essex;IG39By;
00000.0251600000
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 checkdigitsinaddress( const char* string )
{
for( int i =0; i<=1; i++ )
if( !isdigit( string )){}
return false;
for(i=1; i<=2; i++)
if( string != isalpha(string) || string !=
isdigit(string)){}
return false;
for(i= 1; i<=2; i++)
if( string == isalpha(string)){}
for(i= 2; i <=3; i++)
if(string != isalpha(string)){}
return false;
for(i= 1; i<=2; i++)
if( string == isdigit(string)){}
for(i= 2; i <=3; i++)
if(string != isalpha(string) || string !=
isdigit(string)){}
return false;
for( i= 2; i<=3; i++)
if( string == isalpha(string)){}
for(i= 3; i<=4; i++)
if(string != isalpha(string))
return false;
for(i =2; i<=3; i++)
for(i= 3; i<=4; i++)
if(string != isalpha(string) || string !=
isdigit(string)){}
return false;
for(i= 3; i<=4; i++)
if(string == isalpha(string)){}
for(i=4; i<=5; i++)
if(string != isalpha(string)){}
return false;
for(i= 5; i< 25; i++)
if(string != isalpha(string) && string != ';')
return false;
return true;
}
const char* string, is globally declared. const char* string
=&Newcrecord.customeraddress[0];
bool Processcrecord( ofstream& prnfile, ofstream& validdata, char*
record )
{
strncpy( Newcrecord.customeraddress, &record[27], 60 );
Newcrecord.customeraddress[61] = '\0';
Newcrecord.customeraddress[61] = atol(Newcrecord.customeraddress);
if( !checkdigitsinaddress( Newcrecord.customeraddress )){
prnfile<<"Invalid: 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;Ilford;Essex;IG39By;
00000.0251600000
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.