1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
| void chargementproduit ()
{
Hitech nouveau;
Alimentaire nouveau1;
string type,nomproduit,marque,categ;
long prix,codebarre,peremp;
FILE* fichier = NULL;
fichier = fopen(test, "r");
if(fichier != NULL)
{
while (!feof(fichier))
{
fscanf(fichier, "%s ",&type);
fscanf(fichier, "%s ",&nomproduit);
fscanf(fichier, "%s ",&marque);
fscanf(fichier, "%f ",&prix);
fscanf(fichier, "%f\n",&codebarre);
if( strcmp(type,"af") || strcmp(type,"aa") )
{
nouveau1.m_nom_produit=nomproduit;
nouveau1.m_marque=marque;
nouveau1.m_prix=prix;
nouveau1.m_code_barre=codebarre;
nouveau1.m_peremption=peremp;
}
if( strcmp(type,"ht"))
{
fscanf(fichier, "%f ",&categ);
nouveau.m_nom_produit=nomproduit;
nouveau.m_marque=marque;
nouveau.m_prix=prix;
nouveau.m_code_barre=codebarre;
nouveau.m_categorie=categ;
}
}
}
else
printf("Erreur d'ouverture du fichier : %s", nomfichier);
fclose(fichier);
return;
} |
Partager