I did mean both 'name' and 'type' to be strings.
That worked, Thank you so much!
However it is still giving me 2 warning:
scheduling.c:43: warning: format ‘%s’ expects type ‘char *’, but argument 2 has type ‘char (*)[4]’
scheduling.c:43: warning: format ‘%s’ expects type ‘char *’, but argument 6 has type ‘char (*)[3]’
Do you have any suggestion on how to eliminate that?
Code:
#include <stdio.h>
struct process {
char name[4];
int arrival;
int length;
int deadline;
char type[3];
};
int main()
{
// read in all the processes
FILE *fr; // file pointer
fr = fopen ("input_2011.txt", "rt"); // open the file for reading
if (fr == NULL) perror("Error Opening File.");
else {
struct process SP1;
//fscanf(fr,"%s,%d,%d,%d,%s", &SP1.name, &SP1.arrival, &SP1.length, &SP1.deadline, &SP1.type);
fscanf(fr,"%s\t%d\t%d\t%d\t%s", SP1.name, &SP1.arrival, &SP1.length, &SP1.deadline, SP1.type);
printf("%s,%d,%d,%d,%s\n", &SP1.name, SP1.arrival, SP1.length, SP1.deadline, &SP1.type);
}
fclose(fr);
return 0;
}