Programme to add given no of days to the current date to give the resulted date
-
Hi All, I want a C programme which will take a user input as a date and number of days, and then it will add the given number of days to the input date and will give the resulted date. It should keep in mind all the permutation and combinations like changing month year , leap year, some months have 31 days some have 30 days etc.... for eg.: input date 2010-12-25 days 20 result 2011-01-14 This programme can be made but this will take a lot of time if anybody has similar to that or exact programme then please help.... its just a module. Thanks
-
Hi All, I want a C programme which will take a user input as a date and number of days, and then it will add the given number of days to the input date and will give the resulted date. It should keep in mind all the permutation and combinations like changing month year , leap year, some months have 31 days some have 30 days etc.... for eg.: input date 2010-12-25 days 20 result 2011-01-14 This programme can be made but this will take a lot of time if anybody has similar to that or exact programme then please help.... its just a module. Thanks
cmaheshwari16 wrote:
I want a C programme which will take a user input as a date and number of days,
A simple search of your C reference or MSDN would have found these routines[^] for you.
Just say 'NO' to evaluated arguments for diadic functions! Ash
-
cmaheshwari16 wrote:
I want a C programme which will take a user input as a date and number of days,
A simple search of your C reference or MSDN would have found these routines[^] for you.
Just say 'NO' to evaluated arguments for diadic functions! Ash
Sir Thanks for your reply I am working on linux.... and the link you have given... I dont find any function which can add some day to the particular date to give new date. Thanks
-
Sir Thanks for your reply I am working on linux.... and the link you have given... I dont find any function which can add some day to the particular date to give new date. Thanks
-
Thanks Richard..... But I was expecting some live example to get the clear understanding... Its now done by using the below way just creating the object of struct tm and then giving the values to the variables of the structure adding the days to the tm_mday variable using the mktime() function, converting it back to a structure..... and then accessing the required values with the structure variable... I still want to understand the use of the time_t.......if u can......
-
Thanks Richard..... But I was expecting some live example to get the clear understanding... Its now done by using the below way just creating the object of struct tm and then giving the values to the variables of the structure adding the days to the tm_mday variable using the mktime() function, converting it back to a structure..... and then accessing the required values with the structure variable... I still want to understand the use of the time_t.......if u can......
What you describe above sounds fine. The
time_t
type is just a value that represents the current time and date as calculated by the OS that you are running on (i.e. Windows, Linux, AIX etc). Thestruct tm
is created by breaking atime_t
value into its constituent parts to allow for the type of calculation that you are doing. If you go to the link I gave you forstruct tm
and look at the menu in the botttom left pane you will see listed all the various time routines, take a look at each of them to see some sample code.Just say 'NO' to evaluated arguments for diadic functions! Ash
-
What you describe above sounds fine. The
time_t
type is just a value that represents the current time and date as calculated by the OS that you are running on (i.e. Windows, Linux, AIX etc). Thestruct tm
is created by breaking atime_t
value into its constituent parts to allow for the type of calculation that you are doing. If you go to the link I gave you forstruct tm
and look at the menu in the botttom left pane you will see listed all the various time routines, take a look at each of them to see some sample code.Just say 'NO' to evaluated arguments for diadic functions! Ash
Hi Richard, Now its more clear...... Thanks
-
Hi Richard, Now its more clear...... Thanks