Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

mm/dd/yyyy format

Status
Not open for further replies.

7626

Programmer
Sep 13, 2001
1
US
try it get date input in mm/dd/yyyy format such as:
08/07/2001.

but when I declared Int variable like:
int mm, dd, yy;

when I read in the input, only 01 up to 07 are working
and considering 08 and 09 as octal values.

Beside creating an char array to store them and convert back
to Int type, Is there a simple way to do it?

thank in advance,
 
if you are using cin for input try

cin>>dec>>mm;
etc..

dec specifies decimal

i believe there is also ios::dec if using iostreams or fstreams.

However... if you know that the values are coming in in octal you can always convert em back to decimal.


THere is another alternative and that is to read the values in to strings instead of ints. Then use strtol

char* endPtr;
strtol(mm /*mm is now a char array*/,endPtr,10);

the value returned from strtol should be the decimal equivalent.

Matt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top