learning-cc4e

Solution to https://cc4e.com/. If you copy these you're not right in the head.
git clone https://kaka.farm/~git/learning-cc4e
Log | Files | Refs

main.c (728B)


      1 #include <stdio.h>
      2 #include <stdlib.h>
      3 
      4 struct simpledate {
      5     int day;
      6     int month;
      7     int year;
      8 };
      9 
     10 static int day_tab[2][13] = {
     11   {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31},
     12   {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}
     13 };
     14 
     15 
     16 main() {
     17     void dump_date();
     18     printf("Playing with structures\n");
     19     struct simpledate sd;
     20 
     21     sd.year = 2023;
     22     sd.month = 2;
     23     sd.day = 11;
     24     dump_date(&sd);
     25     printf("Day of year %d\n", day_of_year(&sd));
     26 
     27     sd.year = 2023;
     28     sd.month = 9;
     29     sd.day = 15;
     30     dump_date(&sd);
     31     printf("Day of year %d\n", day_of_year(&sd));
     32 
     33     sd.year = 2024;
     34     sd.month = 9;
     35     sd.day = 15;
     36     dump_date(&sd);
     37     printf("Day of year %d\n", day_of_year(&sd));
     38 }