Hi,
am I right in thinking that calling p_fp[IN_FILE] will always go to the _start_ of the file ?
in the snippet below, I am getting a count from LAST_FILE but not from IN_FILE, I have swapped them round just in case and when I do I get 5 0 instead of 0 5 and I should be getting 9 5 or 5 9
I think I have included everything that is relevant,
Code:
#define OPEN_FILE_COUNT 6
#define IN_FILE 0
#define OUT_FILE 1
#define LOG_FILE 2
#define YEAR_FILE 3
#define HIST_FILE 4
#define LAST_FILE 5
FILE * p_fp[OPEN_FILE_COUNT];
void file_open(char * inp_file, char * last_month, FILE ** fp)
{
if(!(fp[IN_FILE] = fopen(inp_file, "r")))
error_func("In file_open().", "Error : fopen(INPUT_FILE)", SYS | FATAL);
... /* same for all files */
void check_activity(FILE ** p_fp)
{
int countA = 0, countB = 0;
char ch;
while((ch = fgetc(p_fp[IN_FILE])) != EOF)
if(ch == '\n')
countA++;
while((ch = fgetc(p_fp[LAST_FILE])) != EOF)
if(ch == '\n')
countB++;
printf("this month, last month %d %d\n", countA, CountB);
...
tia,