hi i have a problem trying to initialize the members of the structure...i am getting errors i don't really know what to do next...could someone please help me solve this problem. what the program is suppose to do is to print the whole array of a calendar year showing the month, day and the number of that month when the user enters the value one
Code:
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define DAYS 12
#define MONTH 12
struct cal {
int number;
char months[MONTH][MONTH];
int days[DAYS];
};
int main(void){
struct cal library = {.months[MONTH][MONTH] = {{"jan"}, {"feb"}, {"mar"}, {"apr"}, {"may"}, {"jun"}, {"jul"}, {"aug"}, {"sep"}, {"oct"}, {"nov"}, {"dec"}},
.days[DAYS] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}
}
int index;
int menu;
printf("The menu options\n");
printf("1. Print Array\n");
printf("2. Set Days for a Month\n");
printf("3. Display Days for a Month\n");
printf("4. Quit\n");
printf("Please enter the option you want to proceed with\n");
scanf("%i", &menu);
if(menu==1)
{
for (index =0; index < DAYS && index < MONTH; index++){
printf("Month %2d which is %s has %2d days\n", index +1, library.months[index], library.days[index]);
continue;
}
}
else
printf("No good");
return 0;
}