943,957 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 519
  • C++ RSS
Sep 4th, 2009
0

requiring date validating program

Expand Post »

hi can any one send me the date validating program plz..........
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
s_48 is offline Offline
3 posts
since Sep 2009
Sep 4th, 2009
0
Re: requiring date validating program
i have done this but now i require to check the format dd/mm/yyyy and for leap yers also,some programs are there but i need the complete program can any one help.....
Reputation Points: 10
Solved Threads: 0
Newbie Poster
s_48 is offline Offline
3 posts
since Sep 2009
Sep 4th, 2009
0

Re: requiring date validating program

#include "stdafx.h"
#include <iostream.h>
#include <stdio.h>
#include <conio.h>

struct date
{
int day;
int month;
int year;
};

struct date today,tomorrow;

int main()
{
const int days_month[12] ={31,28,31,30,31,30,31,31,30,31,30,31};

printf("enter today's day,month and year\n");
scanf("%d%d%d",&today.day,&today.month,&today.year);
if (today.day != days_month[today.month-1])
{
tomorrow.day = today.day + 1;
tomorrow.month = today.month;
tomorrow.year = today.year;
}
else
{
tomorrow.day = 1;
tomorrow.month = today.month + 1;
tomorrow.year = today.year;
}

if ((today.month==12)&&(days_month[today.month-1] == today.day))
{
tomorrow.month=1;
tomorrow.year=today.year+1;
}
else
{
tomorrow.year=today.year;
}
printf("Today's date is %d/%d/%d\n", today.day, today.month,
today.year);
printf("Tomorrow's date is %d/%d/%d\n", tomorrow.day,
tomorrow.month, tomorrow.year);

getch();
return 0;
}
Reputation Points: 10
Solved Threads: 0
Newbie Poster
s_48 is offline Offline
3 posts
since Sep 2009
Sep 4th, 2009
0

Re: requiring date validating program

Maybe this works for normal years, but not for leap years.
Reputation Points: 395
Solved Threads: 71
Posting Whiz
jencas is offline Offline
362 posts
since Dec 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: how can i get this delete function working pls!!!
Next Thread in C++ Forum Timeline: Oops (c++)





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC