typical problem in C++... hot to solve

hello every one.
i have this problem in c.

i have to check that the input date doesnot exceed the tomorrow date.
eg. if input date = 12-10-2004
then it should be always less than 12-12-2008
because today is 11-12-2008.

and input date should be valid one.
like jan is 30 days.
dec is 31 days.
feb is 28 ( if not leap year)....

how to solve this problem
 
I

Ian Collins

@$|-|. DUBEY said:
hello every one.
i have this problem in c.

i have to check that the input date doesnot exceed the tomorrow date.
eg. if input date = 12-10-2004
then it should be always less than 12-12-2008
because today is 11-12-2008.

and input date should be valid one.
like jan is 30 days.
dec is 31 days.
feb is 28 ( if not leap year)....

how to solve this problem

By writing some code. What have you tried?
 

By writing some code.  What have you tried?

since i am working on this embedded thing.
i don't have lot of option....
but i am trying hard...
some help could be more better.
i can access local date...
i have input date.
now i have to find algorithm to sort the date....
 
R

Ron AF Greve

Hi,

Can't you just concatenate the dates like this
YYYYMMDD
Date1BeforeDate2 = date1 < date2

To validate input dates you might want to look at mktime (but not sure if
you can validate time with it).

If I have a database server around (for instance oracle) I usually abuse the
sysdate function to generate or test dates (but I guess that is not an
option for embedded stuff).

Regards, Ron AF Greve
 
W

webdoggy2

Message: sorry for bothering you i was just wondering if you could
help me with a poker game that i have to create.I used an array to a
class in order to create different players.I have to create a function
that saves the status of the game like nWins, money and so on, but im
not sure how to do this.

Thanks

void savePlayerData(clPlayer *playerData)
{
int x;
ofstream playerdata("playerdata.dat");
playerdata<<playerData[x].money<<playerData[x].nWins<<playerData
[x].nGamesPlayed
<<playerData.totalAmountWon<<playerData.totalAmountBet;
 
R

Ron AF Greve

Hi,

Lookup object serialization either in this newsgroup or using google.

Regards, Ron AF Greve
 
V

Vaclav Haisman

@$|-|. DUBEY wrote, On 11.12.2008 11:37:
since i am working on this embedded thing.
i don't have lot of option....
but i am trying hard...
some help could be more better.
i can access local date...
i have input date.
now i have to find algorithm to sort the date....
If you can use Boost then use it and its excelent DataTime library.

--
VH



-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)

iFYEAREIAAYFAklBULsACgkQhQBMvHf/WHkpAgDgydtwmuNbi4EQI5RrTIx3ywPq
Z9PDBXYdNcvPZQDgs/pPi1TvEiKBEkF8n51MHfVtfDZzzL3kWJGKGg==
=hQUj
-----END PGP SIGNATURE-----
 

well people i got it....
and good thing is i solved this problem my self.

here is what i have done....
correct me if i am wrong any where.

i have current date... ddmmyyy ( 12/12/2008 )
i have user date....ddmmyyy ( 14/03/1983 )
i reversed the both date to yyyddmm
so i get....

m_crnt_date = 20081212;
m_my_dob = 19831402;

since both are converted to integer formate
it can be compared....
if( m_my_dob >= m_crnt_date )

that's done...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,120
Latest member
ShelaWalli
Top