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
 
G

Guest

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

how far have you got?
If I were you you I'd take a look at the stuff in time.h.
There's a reference here
http://www.dinkumware.com/manuals/?manual=compleat&page=time.html

Start by writing a program to print today's date.
 
J

James Kuyper

@$|-|. DUBEY said:
(e-mail address removed) wrote: ....


i didn't get what you want to say...
i am using a embedded device.
can you explain further.

1. Read the documentation for the functions declared in time.h.
2. Figure out how to use those functions to achieve what you want to do.
If you can't figure it out, post a message explaining what you're having
trouble understanding. Don't just say "I don't understand" - be
specific, demonstrate that you actually have bothered trying to understand.
3. Write corresponding code. If you can't get it to compile or link,
post the code, along with the error messages you got from the compiler
or linker. If you couldn't get it to work right, post the code and the
output from your program that demonstrates that the it didn't work
correctly.
 
O

osmium

@$|-|. DUBEY said:
----
do you have some typical algorithm..
for this problem
i have current date.....
and user input date....

My first thought would be to use Julian day, *not* date. You could look it
up on the Internet. NB that Julian has two distinct meanings WRT calendars.
 
G

Guest

how far have you got?
If I were you you I'd take a look at the stuff in time.h.
There's a reference here
http://www.dinkumware.com/manuals/?manual=compleat&page=time.html
Start by writing a program to print today's date.

don't quote sigs (the bit after "-- ")
i didn't get what you want to say...

I'm sorry. Which bit of my post was unclear?
i am using a embedded device.

Does it support the full standard C library? If so then the fact
you are on an embedded device makes no odds (presuming it
actually has the time of day available). If not you are on
your own, you'll need a ng devoted to your embedded platform.
can you explain further

explain what?

Note: I'm not going to write the program for you
 
G

Guest

do you have some typical algorithm..
for this problem
i have current date.....
and user input date....

what's next

perhaps you want the difference between them.
Is there a function that would help with that in time.h?
 
C

CBFalconer

@$|-|. DUBEY said:
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)....

I suggest you start by recording all dates in ISO format, which is
precisely yyyy-mm-dd (possibly followed by time data). Note that
the numbers include leading zeroes. With this, comparison of dates
can by done by comparison of strings (with strcmp()).

Use of non-standard format results in all sorts of special code.
 
K

Keith Thompson

@$|-|. 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)....

You might want to take a look at a calendar for January.
 

Here's what's next, tell your employer to hire a qualified C
programmer.  I've been doing embedded systems in C for more than 25
years, what will they pay someone who already knows how to do your
job?

--
Jack Klein
Home:http://JK-Technology.Com
FAQs for
comp.lang.chttp://c-faq.com/
comp.lang.c++http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++http://www.club.cc.cmu.edu/~ajo/docs/FAQ-acllc.html

wow,
so rude,
some day i will have 25 years of experience and i wouldn't say these
words to any newbee.
man you think, you are trying to steal a lollypop from kid,
watch out.....


well see how i solved the problem
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...

can you comment on this......
 
J

Joachim Schmitz


Please stop quoting signatures, the "-- " and following lines. You've been
told before (by Nick Keighley, in this thread)
wow,
so rude,
some day i will have 25 years of experience and i wouldn't say these
words to any newbee.
man you think, you are trying to steal a lollypop from kid,
watch out.....


well see how i solved the problem
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...

If comparision is your only intention, yes, that'll work. If you need to
calculate e.g. days between dates, this won't do. Have a look at the time
and date related functions, as been told before (by James Kuyper)

Bye, Jojo
 
T

td didi

@$|-|. DUBEY said:
wow,
so rude,
some day i will have 25 years of experience and i wouldn't say these
words to any newbee.
man you think, you are trying to steal a lollypop from kid,
watch out.....


well see how i solved the problem
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...

can you comment on this......

Hi,

Shouldn't you use yyyymmdd instead for comparison?
 

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

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top