Hi all !
My problem is that every time i open the program the number of recorods is multiplied. The records are normally saved in the file when the user exit the program or when the number of records is more than 20. I've got two static variables that suppose to control this process. One of them (static int cpt) is global to the program. The second (static int total) - is local and used as an anchor when the saving is actually takes place. Why on earth doesn't it work????????
Here goes my saving function:
/* APPEL - file name */
/* appel - structure name */
void ajout_nom_f()
{
static int total=0;/* pour compter le nombre d'enregistrements deja ecrits dans le nom_f */
int i; /* compteur local */
if((APPEL=fopen(nom_f,"a"))==NULL) /* ouverture nom_f dans le mode d'ajout - append */
{ err_msg("* * * Erreur du systeme! * * *\n");
return;}
for (i=total;i<cpt;i++)
{
fwrite(&tab_ap[i],sizeof(appel),1,APPEL); /*ajout du structure au nom_f*/
}
total = cpt;
fclose(APPEL);
return;
}