I get a continuous loop running after the info in the file has finished. The loop is filled with funny y characters.
Code:
void open_batch()
{
int eof = FALSE;
FILE *fp;
char f[30];
char c;
int a = 0, b = 0;
int d, e, g = 0, h = 0, i = 0, j = 0, k = 0, l = 0;
printf("Please enter the file you wish to run: ");
scanf("%s", &f);
l = getchar();
fp = fopen(f,"rt");
if(fp == NULL)
{
printf("No such file\n");
menu();
}
while(eof == FALSE)
{
c = fgetc(fp);
while(c == 32)
{
c = fgetc(fp);
}
if((c == 'F') || (c == 'U') || (c == 'f') || (c == 'u'))
{
for(d = 0; d <= 3; d++)
{
u_type[d] = c;
c = fgetc(fp);
printf("%c", u_type[d]);
}
printf(" ");
while(c == 32)
{
c = fgetc(fp);
}
for(e = 0; e <= 2; e++)
{
unit_no[e] = c;
c = fgetc(fp);
printf("%c", unit_no[e]);
}
printf(" ");
while(c == 32)
{
c = fgetc(fp);
printf("1", c);
}
printf(" ");
sym = fgetc(fp);
printf("%c", sym);
c = fgetc(fp);
while(c == 32)
{
c = fgetc(fp);
}
printf(" ");
}
for(g = 0; g < 3; g++)
{
h_no[g] = c;
c = fgetc(fp);
printf("%c", h_no[g]);
}
printf(" ");
while(c == 32)
{
c = fgetc(fp);
}
while(c != 32)
{
st_name[h] = c;
c = fgetc(fp);
printf("%c", st_name[h]);
h++;
}
printf(" ");
while(c == 32)
{
c = fgetc(fp);
}
while(c != 32)
{
st_type[j] = c;
c = fgetc(fp);
printf("%c", st_type[j]);
j++;
}
printf(" ");
while(c == 32)
{
c = fgetc(fp);
}
while(c != 32)
{
sub_name[k] = c;
c = fgetc(fp);
printf("%c", sub_name[k]);
k++;
}
printf(" ");
while(c == 32)
{
c = fgetc(fp);
}
for(l = 0; l < 4; l++)
{
postcode[l] = c;
c = fgetc(fp);
printf("%c", postcode[l]);
}
while(c != '\n')
{
c = fgetc(fp);
}
if(c == EOF)
{
eof = TRUE;
}
}fclose(fp);
}