this might help a little, it will convert a string to a long, extracting only numbers and leaving everything else out:
Code:
long stringtolong(char tempstr[])
{
long templong=0;
int counter;
for(counter=0;tempstr[counter]!='\0';counter++)
if(tempstr[counter]>='0' && tempstr[counter]<='9')
templong = templong*10 + tempstr[counter]-'0';
return templong;
}
P.S. if you want the first 3 digits then the next two, then change the function to allow parsing of start/finish points, ie:
Code:
long firstchars;
long restchars;
long stringtolong(char tempstr[],int start, int end)
{
long templong=0;
int counter;
for(counter=start;counter<=end;counter++)
if(tempstr[counter]>='0' && tempstr[counter]<='9')
templong = templong*10 + tempstr[counter]-'0';
return templong;
}
firstchars = stringtoolong(phonenumber,0,2);
restchars = stringtoolong(phonenumber,3,strlen(phonenumber));
the firstchars should have only the first 3 numbers and the restchars should have all the rest.
Hope this helps