i have a seg fault please help. It happens when i go to open a file. if the file has data i get a seg fault. if the file is empty its all ok and i get the proper message.
Code:
void open_batch()
{
char f[100];
char c;
int a = 0, b = 0;
int eof = 0;
int d, e, g, h, i, j, k;
printf("Please enter the file you wish to run: ");
scanf("%s", f);
if(file == NULL)
{
printf("File is empty!\n\n");
exit(1);
}
while(eof == 0)
{
c = fgetc(file);
if((c == 70) || (c == 102) || (c == 85) || (c == 117))
{
for(d = 0; d <= 3; d++)
{
u_type[d] = c;
c = fgetc(file);
printf("%c", u_type[d]);
}
...
...