if i have a CString that is "30/2/2002"
how can i make that i make the 30 to one variable and 2 to another...
is there any function that will allow mi to do it ???
if i have a CString that is "30/2/2002"
how can i make that i make the 30 to one variable and 2 to another...
is there any function that will allow mi to do it ???
Run through a for loop from 1 to strlen(yourstring). Set 2 int variables to hold position of last "/" and current "/". On each iteration of the loop test to see if you've encountered a "/" if you have use the 2 position-holding int's to get the section of data you need. Set your variable to that data (after you convert it from
int to char/string).
how you use itOriginally posted by jdinger
Run through a for loop from 1 to strlen(yourstring). Set 2 int variables to hold position of last "/" and current "/". On each iteration of the loop test to see if you've encountered a "/" if you have use the 2 position-holding int's to get the section of data you need. Set your variable to that data (after you convert it from
int to char/string).
can u have any example??
PS try storing the dates as a longCode:char *pStart=NULL,sString[64]; pStart=sString;//set to the start of the buffer while(*pStart!='\0') { iNumber1=atoi(pStart); while(*pStart++ != '/'); iNumber2=atol(pStart); while(*pStart++ != '/'); iNumber3=atoi(pStart); }
30 April 2002 = 30042002 (depending where you live)
and writting some functions to convert between them.
Some macros like
#define GETDAY(lDate) (lDate / 1000000)
#define GETMONTH(lDate) ((lDate / 10000) % 100)
#define GETYEAR(lDate) (lDate % 10000)
will help
"Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
Friedrich Nietzsche
"I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
George Best
"If you are going through hell....keep going."
Winston Churchill