function problem - freezing
Hello people, I'm getting some problems with the following function:
The first extern is to get a global array of structures declared in main.c, this file is market.c.
extern struct product products;
int loadDB (struct product products, char *filepath)
FILE *fpData; /* pointer to the file that we'll get the data */
int i = 0; /* the index for filling the structure array */
/* try to open the file and check for errors */
if ((fpData = fopen(filepath,"r")) == NULL)
while (fscanf(fpData,"%d%d%d%f%s%s%s%s",&products[i].pr_code,&products[i].pr_inv,&products[i].pr_min_inv, &products[i].pr_price, products[i].pr_name,products[i].pr_supplier,products[i].pr_sup_tel,products[i].pr_sup_fax) == 8)
/* check if we at least got a single value, if not, return fail (0) */
if (products.pr_code == 0)
My program freezes when I call this function, I can see the HEEE msg, but afters this, all goe's down.