I need to basically make a loop where i read everyline in a file but how would i tell the loop to stop when it reaches the end of a file?
while (empinfo <<my filename != \0)
i tired that but that was useless
Code:
empinfo = fopen("employees.dat", "r");
if (fp == NULL) {
printf("Cannot open %s\n", fp);
}
else {
/*printf("What is the 4 digit employee number: ");
scanf("%s", first);*/
do {
fscanf(empinfo, "%d:%[^:]:%[^:]:%d:%lf\n", &empnum, last, first, &emprate, &emphours);
printf("%s ", first);
k++;
} while (k != 6);
fclose(empinfo);
}
thats what im doing right now, but i need it to find out when to stop since ill be adding lines into the file so i cant go into the code manually everytime