[c]Why first file is creating after the second. How to avoid

Hi,

My Code is as below:

nbECRITS = fwrite(strstr(data->buffer, ";") + 1, sizeof(char), (data->buffsize) - LEN_NOM_FIC, fic_sortie);
  fclose(fic_sortie);
 
 
 sprintf(PATH_BALISE, "%s.balise", PATH);
fic_balise_data = fopen(PATH_BALISE, "a+");
if (fic_balise_data == NULL) {
fprintf(fic_log, "\nErreur sur l'w mq.exe, au niveau de la creation du fichier balise de sortie \"%s\": ", PATH_BALISE);
fprintf(fic_log, "\ncreation impossible\n");
CR = ERR_FICHIER_BALISE;
break;
}

Here fic_sortie associated file is sometimes created after the file with .balise extension.[x:1000].
What is the bug here in this code.

Thanks for you time and reply...:slight_smile:

Can you post more of the code because it is hard to understand as is...and also indent and format it properly so it is legible..