fork download
  1. #include <stdio.h>
  2. #include<string.h>
  3. struct day
  4. {
  5. char name[20];
  6. int date;
  7. char activity[30];
  8. };
  9. typedef struct day Day;
  10. void create(Day[],int);
  11. void read(Day[],int);
  12. void display(Day[],int);
  13. int main()
  14. {
  15. #define SZ 3
  16. Day planner[SZ];
  17. create(planner,SZ);
  18. read(planner,SZ);
  19. display(planner,SZ);
  20. return 0;
  21. }
  22. void create(Day planner[],int size)
  23. {
  24. for(int i=0;i<size;i++)
  25. {
  26. strcpy(planner[i].name,"");
  27. planner[i].date=0;
  28. strcpy(planner[i].activity,"");
  29. }
  30. }
  31. void read(Day planner[],int size)
  32. {
  33. for(int i=0;i<size;i++)
  34. {
  35. printf("DAY %d:",i+1);
  36. printf("enter name of the day\n");
  37. scanf("%s",planner[i].name);
  38. printf("enter date in numeric\n");
  39. scanf("%d",planner[i].date);
  40. printf("enter activity\n");
  41. scanf("%s",planner[i].activity);
  42. }
  43. }
  44. void display(Day planner[],int size)
  45. {
  46. printf("====planner activity system====");
  47. printf("%-10s %-6s %-30s","Day","Date","Activity");
  48. printf("------------------");
  49. for(int i=0;i<size;i++)
  50. {
  51. printf("%-10s %-6d %-30s",planner[i].name,planner[i].date,planner[i].activity);
  52. }
  53. }
Success #stdin #stdout 0.01s 5276KB
stdin
45
stdout
DAY 1:enter name of the day
enter date in numeric
enter activity
DAY 2:enter name of the day
enter date in numeric
enter activity
DAY 3:enter name of the day
enter date in numeric
enter activity
====planner activity system====Day        Date   Activity                      ------------------45         0                                               0                                               0