-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathcalender.c
More file actions
64 lines (57 loc) · 1.16 KB
/
Copy pathcalender.c
File metadata and controls
64 lines (57 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include <stdio.h>
#include <stdlib.h>
#define days 7
typedef struct activity
{
char* nday;
int dday;
char* desc;
}plan;
plan* create();
void read(plan*);
void display(plan*);
int main()
{
plan* cal = NULL;
cal = create();
read(cal);
display(cal);
return 0;
}
plan* create()
{
plan* t = NULL;
t = (plan*) malloc(days * sizeof(plan));
if (t == NULL)
{
printf("Memory not Allocated");
return 0;
}
return t;
}
void read(plan* P)
{
for (int i = 0; i < days; i++)
{
P[i].nday = (char*) malloc (sizeof(char) * 10);
P[i].desc = (char*) malloc(sizeof(char) * 100);
printf("Enter day (name) : ");
scanf("%s", P[i].nday);
printf("Enter date : ");
scanf("%d", &P[i].dday);
printf("Enter desc : ");
scanf("%s", P[i].desc);
printf("\n");
}
}
void display(plan* P)
{
printf("\n\n Activity plan for %d days is : \n\n", days);
for (int i = 0; i < days; i++)
{
printf("Name of Day : %s\n", P[i].nday);
printf("Date of Day : %d\n", P[i].dday);
printf("DESC : %s\n", P[i].desc);
printf("\n");
}
}