![]() |
| ||
| need urgent responce please! i am designing a code that will calculate tomorrows date but there is some problem with the code, when i enter year = 2008 or anyother month =12 day = 31 it gives tmorrows date as 1/2/2008 please help and tell me if i can do more improvements thanks #include<conio.h> |
| ||
| Re: need urgent responce please! You are kicking off December! :P Check if(m<=0 || m>=12). It should be if(m<=0 || m>12). Also check your leap years handling. |
| ||
| Re: need urgent responce please! Before you do the above, migrate to the C forum Chris |
| ||
| Re: need urgent responce please! Can you use the functions in time.h? If you can, then just fill in a struct tm and call mktime() to calculate tomarrow #include <time.h> |
| ||
| Re: need urgent responce please! http://www.catb.org/~esr/faqs/smart-...ns.html#urgent Not to mention, the unindented code which is simply awful to look at. |
| ||
| Re: need urgent responce please! Quote:
main returns an integer. So it's int main()not just main(void). This test condition is wrong: else if(d==i&&m==2) You aren't checking for leap years, although at one point you do find i=y%4;. Comparing this value with the number of days screws up the whole thing. |
| All times are GMT -4. The time now is 4:16 am. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC