you could try somethign like this:
Code:
...
void clip(char*,int); //prototype for a function to come later
...
int main() //start the driver function after the includes and prototype
...
char*Data,cDay,cMonth,cYear; //declare char arrays for each
Data=new char[20]; //allocate memory
cDay=new char[5]; //allocate memory
cMonth=new char[5]; //more of the same
cYear=new char[5]; //one more time
int Day,Month,Year; //create integers (allocate memory ;) )
...
strncpy(data,cDay,2); //copy the first two characters into cDay
Day=atoi(cDay); //turn cDay into an integer and store in Day
clip(Data,2); //trim off those first two characters
...
}
void clip(char*Data,int index) //custom function
{
int Length=strlen(Data)-index; //the new length is going to be the current length minus what you take off
for(int i=0;i<index;i++) //go through the inner loop for as many chars as your taking off
{
for(int x=0;x<Length;x++) //go through the entire string
Data[x]=Data[x+1]; //move each character up one space
}
Data[Length]='\0'; //make sure there's a null-termination where you want it
}
IANAL (heh), and I have no clue if that will work... there's also probably a standard (or at least widely accpted) function to take the place of my 'clip' function, but I can't seem to remember one for now...
your best bet is to probably look into the string class because that would make all this alot easier and get you away from the C-style strings you've been using...