Skip to content

Commit

Permalink
Complete Overhaul
Browse files Browse the repository at this point in the history
Complete overhaul of how it calculates how many days till christmas and how it prints the eves. Fixed issues where the application would print empty memory addresses and freak out. Less memory usage.
  • Loading branch information
CThompson01 committed Dec 25, 2018
1 parent 0ab6fa6 commit b0164af
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,23 @@ void main() {

// gets the day
int month = timeStructure.tm_mon;
int day = (timeStructure.tm_mday + prevDays[month]) + 6;
int date = timeStructure.tm_mday;
int day = ((date + prevDays[month]) + 6) % 366;

if (day > 365)
day -= 365;

// Calculate the days until christmas
int daysTillChristmas = (365) - (day);
printf("Day: %d\n",day);
printf("Eve Amount: %d\n", daysTillChristmas);

createEve(daysTillChristmas);
}

void createEve(int tilChrist) {
char total[1470];
char eve[] = "eve ";
for (int x=0;x<(tilChrist*4);x++) {
total[x]=eve[x%4];
if (tilChrist < 1)
printf("Merry Christmas!!! :)");
else
printf("Christmas ");

for (int i=0;i<tilChrist;i++) {
printf("Eve ");
}
printf("Christmas %s\n", total);
printf("\n");
}

0 comments on commit b0164af

Please # to comment.