Voici le programme que j'ai fait j'ai retirer qlq lignes de codes qui encombraient pour rien les explications.
J'ai mis des commentaires pour expliquer chaque instruction en rapport avec le fichier excel(fopen,fprintf,fclose).
#include<stdio.h>
int coca,orangeade,limonade,biere,kriek,eaupl,eaupe,billet,rendre,cmd,x;
float total,stot1,stot2,stot3,stot4,stot5,stot6,stot7,caisse;
float boncmd (int x, float y);
/*Déclaration du fichier .txt*/
FILE *fp;
main()
{
cmd=1;
while (cmd < 9999)
{
printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nCoca : 1,5 x ");
scanf("%d",&coca);
stot1 = 1.5 * coca;
printf("\nKriek : 1,5 x ");
scanf("%d",&kriek);
stot5 = 2 * kriek;
total = stot1stot5;
printf("\n\nTotal = %.1f",total);
caisse = caisse + total;
/*Appel fonction pour suavegarder dans un fichier excel*/
boncmd (cmd,total);
while (billet<total)
{
printf("\nArgent recu :");
scanf("%d",&billet);
}
printf("\nA rendre : %.1f",billet-total);
cmd++;
getch();
}
}
/*Fonction pour sauvegarder les valeurs dans un fichier excel*/
float boncmd (int x,float y)
{
/*fopen permet d'ouvrir le fichier excel*/
fp = fopen ("essai1.xls","a+");
/*fprintf permet d'inscrire les valeurs dans le fichier excel*/
fprintf(fp,"%d \t %f \n",cmd,total);
/*fclose permet de fermer le fichier excel*/
fclose(fp);
return 0;
}