Originally Posted by
Huskar
so should i? sorry im very new to this and im in a hurry...
Code:
void read_from_file(FILE *file, STUDENT array[20])
{
int i;
file = fopen("Students.txt", "r");
for(i = 0; !feof(file) && i < 20; i++)
{
fscanf(file, "%lld", &array[i].stud_num);
fread here? then save to array[i].name
fread here? then save to array[i].bday
fread here? then save to array[i].course?
}
fclose(file);
}
is this correct?
sorry, if you're too much in a hurry to learn the language. let me know when you have time, I'll be right over here on the edge of my seat.
Code:
if((file = fopen("Students.txt", "rt" == NULL) {
printf("\n File \"Students.txt\" didn't open - exiting program\n");
exit(1);
}
actually its more like
Code:
if ( (file = fopen("students.txt", "r") ) == NULL) {
also you don't need to add a 't' token there. because
Code:
fopen(const char *filename, "r")
opens a filename for reading in text mode by default anyway. in fact, in place of the 't' why don't you put any letter from a - z (except b) and tell me what happens.