Program 1)
Program 1)
Program 1)
h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#define NUM_DAYS_IN_WEEK 7
int i;
//Prototypes
void FreeCal(DAYTYPE *);
void DispCal(DAYTYPE *);
void ReadCal(DAYTYPE *);
DAYTYPE *CreateCal();
//Main function
int main()
{
// Create the calendar
DAYTYPE *weeklyCalendar = CreateCal();
return 0;
}
return calendar;
}
// Read Calender function definition
void ReadCal(DAYTYPE *calendar)
{
char Choice;
for( i = 0; i < NUM_DAYS_IN_WEEK; i++)
{
printf("Do you want to enter details for day %d [Y/N]: ", i + 1);
scanf("%c", &Choice);
getchar();
if(tolower(Choice) == 'n')
continue;
printf("Day Name: ");
char nameBuffer[50];
scanf("%s", nameBuffer);
calendar[i].acDayName = strdup(nameBuffer); // Dynamically allocate and copy
the string
printf("Date: ");
scanf("%d", &calendar[i].iDate);
printf("Activity: ");
char activityBuffer[100];
scanf(" %[^\n]", activityBuffer); // Read the entire line, including spaces
calendar[i].acActivity = strdup(activityBuffer);
printf("\n");
getchar(); //remove trailing enter character in input buffer
}
}
/* Output
Day 2:
Day Name: Tuesday
Date: 28102023
Activity: FDP conduction
Day 3:
Day Name: Wednesday
Date: 29102023
Activity: Proposal Writeup
Day 4:
Day Name: Thursday
Date: 30102023
Activity: Data Analysis
Day 5:
Day Name: Friday
Date: 31102023
Activity: Article Review
Day 6:
Day Name: Saturday
Date: 1112023
Activity: Week Off Enjoy
Day 7:
Day Name: Sunday
Date: 2112023
Activity: Enjoy
Day 2:
No Activity
Day 3:
No Activity
Day 4:
No Activity
Day 5:
No Activity
Day 6:
No Activity
Day 7:
Day Name: sunday
Date: 7112023
Activity: Enjoy