Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Your program will need to do the following: 1. Read in a list of calendar remind

ID: 3624828 • Letter: Y

Question

Your program will need to do the following:
1. Read in a list of calendar reminders from a file called “reminders.txt” (they will be stored initially as “mm/dd reminder_string”…e.g., “04/19 Exam 2 in ECE 285”). Store these strings in a two dimensional array. There will be no more than 30 reminders in the file, and each reminder will be less than 30 characters. You can use the read_line() function from the remind.c program on p295 if you like, and the code for main on that page will be a helpful reference (do not copy it!).
2. The reminders will be arranged and printed to two different files. The first file should be called “Dates.txt”, and you should print the list of reminders in order according to month, then day. The second file should be called “List.txt”, and you should print the list of reminders in two columns (Reminder and Date) in alphabetical order as “reminder_string mm/dd” (e.g., Exam 2 in ECE 285 04/19).. You can use any libraries you’d like (the string library is especially useful), and all of this can be in one big *.c file.

Here is the list of reminders:
reminders
04/08 Honor's Day-no classes
04/04 HW 5 due
05/02 Final Exam section 2 from 11:30-2 pm
05/03 Final Exam section 1 from 1-10:30 am
04/28 Last day of class!
04/01 Mom's Birthday
04/23 Dad's Birthday
04/19 Chiropractor 3:45
05/31 My brother comes home!
05/27 Baby shower for Court
05/26 Fly home!
06/03 Family Reunion
01/01 New Year's Day
02/14 Valentine's Day
03/17 St Patrick's Day
07/04 4th of July!
11/24 Thanksgiving
12/25 Christmas
10/31 Halloween
10/24 Anniversary
06/01 Cari's Birthday
12/22 Holly's Birthday
10/03 Russ's Birthday
05/06 Janni's Birthday
03/03 Steve's Birthday
05/01 Lori's Birthday
03/11 My Birthday
04/24 Tami's Birthday
12/25 Crissi's Birthday
02/11 Trevor's Birthday

Explanation / Answer

please rate - thanks

#include <stdio.h>
#include <string.h>

void bydate(char[][61],int);
void byrem(char[][61],int);
int compare(char [],char []);
void substr(char [],char[],int,int);
int main(void)
{FILE *input;


char data[30][61];
int i=0;
input = fopen("reminders.txt","r");
if(input == NULL)
{ printf("Error opening input file! ");
return 0;
}
while(fgets(data[i], 61, input) >0)
i++;
fclose(input);
bydate(data,i);
byrem(data,i);
return 0;

}
void bydate(char a[][61],int len)
{FILE* out;
int i,j;
char temp[61];
out= fopen("Dates.txt","w");
fprintf(out,"date reminder ");

for(i=0;i<len-1;i++)
for(j=i;j<len;j++)
if (strcmp(a[i],a[j])>0)
{
strcpy(temp,a[i]);
strcpy(a[i],a[j]);
strcpy(a[j],temp);
}
for(i=0;i<len;i++)
fprintf(out,"%s",a[i]);
fprintf(out," ");
fclose(out);
}
void byrem(char a[][61],int len)
{FILE* out;
int i,j;
char temp[61];
out= fopen("List.txt","w");
fprintf(out,"reminder date ");

for(i=0;i<len-1;i++)
for(j=i;j<len;j++)
if (compare(a[i],a[j])>0)
{
strcpy(temp,a[i]);
strcpy(a[i],a[j]);
strcpy(a[j],temp);
}


for(i=0;i<len;i++)
{substr(a[i],temp,6,0);
fprintf(out,"%s ",temp);
substr(a[i],temp,0,5);
fprintf(out,"%s ",temp);
}

fclose(out);
}
void substr(char a[],char t[],int n,int m)
{int i,j=0;
if(n<m)
{for(i=n;i<m;i++)
t[i]=a[i];
t[i]='';
}
else
{for(i=n;a[i]!='';i++)
t[j++]=a[i];
t[j-1]='';
}
}

int compare(char a[61],char b[61])
{int i;
for( i = 6; i < 61; ++i)
{
if(a[i] < b[i])
return -1;
else if(a[i] > b[i])
return 1;
else if(a[i]==''&&b[i]=='')
return 0;
else if(a[i]=='')
return -1;
}
}