I have a problem with a loop refusing to stop at the end of file.
Here's the code.
Code:
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <string.h>
#define CHRS 41
#define RANKSIZ 10
void main(void)
{
FILE *rslpf; /* Pointer to file description */
long B_dd, B_mm, B_yyyy, En_dd, En_mm, En_yyyy, result;
char rank[RANKSIZ], stations[CHRS], gender, FulName[30] ;
if ((rslpf = fopen("C:\\rslpf.txt", "r")) == NULL)
{ printf("Cannot open file\n");
exit(EXIT_FAILURE);
}
while (fscanf(rslpf, "%i%*c %[^/]%*c %[^/]%*c %c%*c %i%*c %i%*c %i%*c %i%*c %i%*c %i%*c %[^\n]%*c ",
&result, rank, FulName, &gender, &B_dd, &B_mm, &B_yyyy, &En_dd, &En_mm, &En_yyyy, stations) != EOF)
{
printf("Officer: \nGender: \nDate of Birth: \nDate of Enlistment: \nDepartment: ");
gotoxy(22,1);
printf("%s %i %s", rank, result, FulName);
gotoxy(22,2);
printf("%c", gender);
gotoxy(22,3);
printf("%i/%i/%i", B_dd, B_mm, B_yyyy);
gotoxy(22,4);
printf("%i/%i/%i", En_dd, En_mm, En_yyyy);
gotoxy(22,5);
printf("%s", stations);
getchar();
clrscr();
}
fclose(rslpf);
}
I'd appreciate your help...