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
|
struct produit
{
char nom[30];
char famille[30];
int prix;
};
void add_produit (void)
{
struct produit add;
cout <<"Entrez le nom du produit\n";
cin >>add.nom;
cout <<"Entrez le nom de la famille de produits\n";
cin >>add.famille;
cout <<"Entrez le prix du produit\n";
cin >>add.prix;
ofstream f ("stock.txt",ios::app);
if (!f.is_open())
cout << "Impossible d'ouvrir le fichier en écriture !" << endl;
else
f << add.nom << " " << add.famille << " " << add.prix <<"\n";
f.close();
} |
Partager