It is 330 lines long, hence I didn't post it here. But I have checked and made sure that he problem is somewhere in this part only. After the code, it simply prints the calculation. Though you can see the much older version of the code here: http://www.cplusplus.com/forum/general/40375/
I have added a number of thing in it though. Mainly that the program will work in months apart from April.
I think that the main problem lies in calculating dates.
cur_month is an Input by the user. It asks for the month number (1 for January and so on.) I used it in switch to determine the number of days in each month, using the array. it is not included in the code, but it is asked for by the program using cin. I also have set a loop over it if the entered value is larger than 12 or less than 1.
And one more thing, the problem is persistent for almost every date possible, it gave the correct output for 1, 2 and 3 and seven. But it gives the error if the date is larger, like 28, 26, 13, etc.
Can you tell me how to use the debugger? I couldn't find the option for it apart from the one I was already using (pressing F5), and how do I look for the values using the debugger?
F9 -> remove/add breaktpoint (if you press F5 it runs until there)
F10 -> step into function
F11 -> step over function
how do I look for the values using the debugger?
If the execution stops (breakpoint / step) go to the variable with the mouse pointer and you can see the content.
There're also serveral windows (if there're not already open you can open them with the Debug menu) called auto, local and so forth where you can see the contents of the variables as well at the moment when program stops
I checked it out. I got the root of the problem:
it is for some reason setting the cur_days to 0. Though it should use the value from the array.
Can you find the error here?
I used search to find cur_days in the article. I found it three times. Once when declaring the variable, the second time when defining its value using cur_days = months[cur_month - 1]; and the third time in the equation for dates
Does the position of the variable effect its value? I have used it in the beginning of the int main function (which is also the only function in my code)
EDIT: I don't know why, but it worked after I moved it to just above the equation of dates.