strange function behaviour
From: muser (charlie12345_at_hotmail.com)
Date: 10/13/03
- Next message: Marc Ferry: "Re: matching { } syntax style"
- Previous message: Juan Antonio Domínguez Pérez: "Re: unresolved symbol with shared library"
- Next in thread: Juan Antonio Domínguez Pérez: "Re: strange function behaviour"
- Reply: Juan Antonio Domínguez Pérez: "Re: strange function behaviour"
- Reply: Victor Bazarov: "Re: strange function behaviour"
- Reply: Christian Janßen: "Re: strange function behaviour"
- Reply: EPerson: "Re: strange function behaviour"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 13 Oct 2003 07:24:30 -0700
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[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.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.
- Next message: Marc Ferry: "Re: matching { } syntax style"
- Previous message: Juan Antonio Domínguez Pérez: "Re: unresolved symbol with shared library"
- Next in thread: Juan Antonio Domínguez Pérez: "Re: strange function behaviour"
- Reply: Juan Antonio Domínguez Pérez: "Re: strange function behaviour"
- Reply: Victor Bazarov: "Re: strange function behaviour"
- Reply: Christian Janßen: "Re: strange function behaviour"
- Reply: EPerson: "Re: strange function behaviour"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]