Ok, I'm not entirely sure here, so I suggest a bit of debugging. This is a small debug-app, that simply opens the supplied data.txt file and attempts to do the same as db.c does when reading the file:
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int get_line(FILE *fl, char *buf);
int main(void){
int t[10], retval;
char line[256], letter;
char f1[128], f2[128], f3[128], f4[128], f5[128], f6[128], f7[128], f8[128];
FILE *mob_f = fopen("data.txt", "r");
if (!get_line(mob_f, line)) {
printf("couldn't read a line\r\n");
exit(1);
}
fclose(mob_f);
retval = sscanf(line, "%s %s %s %s %s %s %s %s %d %c", f1, f2, f3, f4, f5, f6, f7, f8, t + 2, &letter);
printf("Got %d results\r\n", retval);
printf("f1-8: %s %s %s %s %s %s %s %s \r\n", f1, f2, f3, f4, f5, f6, f7, f8);
printf("t+2: %d\r\n", *(t+2));
printf("letter: %c\r\n", letter);
}
int get_line(FILE *fl, char *buf)
{
char temp[256];
int lines = 0;
int sl;
do {
if (!fgets(temp, 256, fl))
return (0);
lines++;
} while (*temp == '*' || *temp == '\n' || *temp == '\r');
/* Last line of file doesn't always have a \n, but it should. */
sl = strlen(temp);
while (sl > 0 && (temp[sl - 1] == '\n' || temp[sl - 1] == '\r'))
temp[--sl] = '\0';
strcpy(buf, temp); /* strcpy: OK, if buf >= READ_SIZE (256) */
return (lines);
}