solved question
I'm trying to find the dates within a specific month in 2022 on which a specific weekday will occur i.e. August and Saturday so 6,13,20,27th.
I have a function I can use to find what the first weekday within a month is, again using August 2022 as an example this would be a Monday.
int valid_dname(char *md, char *m){
struct tm tm;
int year = 2022;
memset(&tm, 0, sizeof(tm));
tm.tm_mday = atoi(md);
tm.tm_mon = atoi(m);
tm.tm_year = year-1900;
mktime(&tm);
return tm.tm_wday;
}
Having the weekdays being equivalent to numbers (Sun-0...Sat-6), I want to create an array into which I can put the first day of the month and then fill in the date in which the rest of the weekdays fall within the first week. Like this:
0,1,2,3,4,5,6 <-- day of the week in number form [7,1,2,3,4,5,6]
From here I'd just be doing basic calculations however, I'm currently stuck on how to make the incrementer loop around the array once I get to the Saturday(6), to be able to put a 7 within the Sunday slot.
Hope this makes sense. :)