Hello, Leonard here.

And my next program is a bit of a doozy. I'm making a ToDo List program. I had to make a getData() function to read a file from Notepad, with the day of the month and the task to do on that day and store them into that array, not only that but each task must be randomized ranging 1 to 31, I don't have to worry about the days, even if there's something on the same day. There's also the fact that I have to sort out the input data and print them out sorting by day and make sure that to include searching by task and days to determine whether or not the task is found

But let's not focus on the rest, my focus is on the getData() part I'm stuck on. I just want to solve it so I can focus on the rest on hopefully not have to require help on those other parts. I already changed some of the functions as comments so they will not interfere.

I'm dealing with two errors here left from making it work:
toDoList.c: In function getData': toDoList.c:43: warning: passing arg 1 offgets' from incompatible pointer type
toDoList.c:44: warning: passing arg 1 of `fputs' from incompatible pointer type
I'm looking into what those mean and finding away to fix it.

#include <stdio.h>
#include <stdlib.h>

#define TASK_SIZE 500
#define EVENT_SIZE 50

typedef struct toDoTask {
        int day;
        char task[TASK_SIZE];
        }toDo;

void getData(toDo t[], int n);
/*
void sortToDoList(char *[])
void printToDoList(task *t)
void searchByDay(int *d)
void searchByTask(char *[])
*/
int main(void){
   toDo eventList[EVENT_SIZE];
   getData(eventList, EVENT_SIZE);
   /*sortToDoList();
   printToDoList();
   searchByDay();
   searchByTask();
   */
  return 0;
}

void getData(toDo t[], int n) {
   FILE *fpIn;
   FILE *fpOut;
   int i=0;

   fpIn = fopen("taskList.txt", "r");
   fpOut = fopen("newData.txt", "w");

    if (fpIn == NULL) {
       printf("File cannot be opened\n");
    }
    while(fgets(&t[i], 100, fpIn) != NULL) {
        fputs(&t[i], fpOut);
        i++;
    }

    fclose(fpIn);
    fclose(fpOut);

}
*/
int main(void){
   toDo eventList[EVENT_SIZE];
   getData(eventList, EVENT_SIZE);
   /*sortToDoList();
   printToDoList();
   searchByDay();
   searchByTask();
   */
  return 0;
}

void getData(toDo t[], int n) {
   FILE *fpIn;
   FILE *fpOut;
   int i=0;

   fpIn = fopen("taskList.txt", "r");
   fpOut = fopen("newData.txt", "w");

    if (fpIn == NULL) {
       printf("File cannot be opened\n");
    }
    while(fgets(&t[i], 100, fpIn) != NULL) {
        fputs(&t[i], fpOut);
        i++;
   FILE *fpOut;
   int i=0;

   fpIn = fopen("taskList.txt", "r");
   fpOut = fopen("newData.txt", "w");

    if (fpIn == NULL) {
       printf("File cannot be opened\n");
    }
    while(fgets(&t[i], 100, fpIn) != NULL) {
        fputs(&t[i], fpOut);
        i++;
    }

    fclose(fpIn);
    fclose(fpOut);

}
/*
  srand(time(NULL));

I'm open to some help.

fgets requires a char* as the first argument. You are passing a toDo* type. I assume that the day element of toDo is equal to the line number? In any case, pass fgets t[i].task into fgets and then set t[i].day to i.

This article has been dead for over six months. Start a new discussion instead.