Euhmm Ok i got some error that tells me that i can't open the program because there some error in my syntax but I really don't know where is the problem it self.

#include <iostream>
#include <iomanip>
#include <cmath>
#include <fstream>
using namespace std;
void voircatalogue(fstream&);
void ajoutitem(fstream&);
void ajoutclients(fstream&);    
char rep=' ';
char unproduit;

struct produits
{
    int ID;
    char nom[60];
    char description[60];
    double prix;
    int Nbinv;
};
int main()
{
    fstream produits("Fproduits.dat",ios::in|ios::out);


 There is where i call my things.

----------------------------------------

void ajoutitem(fstream &produits)
{
    fstream FFproduits("Fproduits.dat", ios::in|ios::out|ios::binary);
    if ( !FFproduits)
    {
        cerr <<"Ouverture Impossible";
        exit(1);
    }
    [U]produits unproduit = {0,"","",0,0};[/U]
    for (char i=' '; i=='n' || i=='N'; i++)
    {
        FFproduits.write(reinterpret_cast<const
            char*>(&unproduit), sizeof(produits));
    }
    [U]produits unproduit;[/U]
    do
    {
    cout<<"Entrez le ID de l'item :"<<endl;
    cin>>unproduit.ID;
    cout<<"Entrez le nom de l'item :"<<endl;
    cin>>unproduit.nom;
    cout<<"Entrez la description de l'item :"<<endl;
    cin>>unproduit.description;
    cout<<"Entrez le prix de l'item :"<<endl;
    cin>>unproduit.prix;
    cout<<"Entrez le nombre en inventaire de l'item :"<<endl;
    cin>>unproduit.Nbinv;
    cout<<"Un autre produit(O\N) ?:"<<endl;
    cin>>rep;
    FFproduits.seekp((unproduit.ID-1) *sizeof(produits));
    FFproduits.write(reinterpret_cast<const char*>(&unproduit), sizeof(produits));
    }
    while (rep == 'n'||rep =='N');
}

There is where it tells me i got a problem. (underlined)

There a lot more code tan that but i don't think that is the prob itself.
the code is in English but the variable are in French :\ .
I would love an answer. Thx at advance

Recommended Answers

All 9 Replies

#include <iostream>
#include <iomanip>
#include <cmath>
#include <fstream>
using namespace std;
void voircatalogue(fstream&);
void ajoutitem(fstream&);
void ajoutclients(fstream&); 
char rep=' ';
char unproduit;

struct produits
{
int ID;
char nom[60];
char description[60];
double prix;
int Nbinv;
};
int main()
{
fstream produits("Fproduits.dat",ios::in|ios::out);


//There is where i call my things.

//----------------------------------------

void ajoutitem(fstream &produits)
{
fstream FFproduits("Fproduits.dat", ios::in|ios::out|ios::binary);
if ( !FFproduits)
{
cerr <<"Ouverture Impossible";
exit(1);
}
produits unproduit = {0,"","",0,0};
for (char i=' '; i=='n' || i=='N'; i++)
{
FFproduits.write(reinterpret_cast<const
char*>(&unproduit), sizeof(produits));
}
produits unproduit;
do
{
cout<<"Entrez le ID de l'item :"<<endl;
cin>>unproduit.ID;
cout<<"Entrez le nom de l'item :"<<endl;
cin>>unproduit.nom;
cout<<"Entrez la description de l'item :"<<endl;
cin>>unproduit.description;
cout<<"Entrez le prix de l'item :"<<endl;
cin>>unproduit.prix;
cout<<"Entrez le nombre en inventaire de l'item :"<<endl;
cin>>unproduit.Nbinv;
cout<<"Un autre produit(O\N) ?:"<<endl;
cin>>rep;
FFproduits.seekp((unproduit.ID-1) *sizeof(produits));
FFproduits.write(reinterpret_cast<const char*>(&unproduit), sizeof(produits));
}
while (rep == 'n'||rep =='N');
}

....Is there any problem with my thread or ? if so tell me i will change it ...

Was trying to make things easier for people who will read ur thread and for myself also, and NO, there is nothing wrong with ur thread..... just trying to understand what the program suppose to do, no hard feelings hey ;)

:O Well thanks, the program need to actually store different items.
Ex: I wanna put the ID , the name, the Info, the price and how many i have left in the back store. That what i'm trying to do. But eh. I HAD to get a ton of errors.

Obvious issues..... for now u can return o or something in line 23 since u use a value-returning function when declaring function main() and close the braces, not that is gona make any defferences to ur errors.

Thx, i made some .. changes... there *full code now"

#include <iostream>
#include <iomanip>
#include <cmath>
#include <fstream>
using namespace std;
void voircatalogue(fstream&);
void ajoutitem(fstream&);
void ajoutclients(fstream&);	
char rep=' ';

struct produit
{
	int ID;
	char nom[60];
	char description[60];
	double prix;
	int Nbinv;
};

struct clients
{
	int ID;
	char nom[60];
	char prenom[60];
};

int main()
{
	fstream FFproduits("Fproduits.dat",ios::in|ios::out); //ouverture des fichiers
	fstream FFclients("Fclients.dat",ios::in|ios::out);
	fstream achat("achat.dat",ios::in|ios::out);

	int ichoix=0;
	int ichoix2=0;
	{
	cout<<setw(70)<<"|^^^^^^^^^^^^^^^^Voici un magasin d'auto^^^^^^^^^^^^^^^^^^^|"<<endl;
	cout<<setw(70)<<"|                                                          |"<<endl;
	cout<<setw(70)<<"|              (1) Administrer mon magasin                 |"<<endl;
	cout<<setw(70)<<"|                                                          |"<<endl;
	cout<<setw(70)<<"|              (2) Faire un achat                          |"<<endl;
	cout<<setw(70)<<"|                                                          |"<<endl;
	cout<<setw(70)<<"|              (3) Quitter le programme                    |"<<endl;
	cout<<setw(70)<<"|__________________________________________________________|"<<endl;
	cout<<"====================>>> Faite votre choix: "<<endl;
	cin>>ichoix;
	}

switch(ichoix)
	{
	case 1:
		{
	cout<<setw(70)<<"|^^^^^^^^^Voici l'administration du magasin d'auto^^^^^^^^^|"<<endl;
	cout<<setw(70)<<"|                                                          |"<<endl;
	cout<<setw(70)<<"|              (1) Voir le catalogue                       |"<<endl;
	cout<<setw(70)<<"|                                                          |"<<endl;
	cout<<setw(70)<<"|              (2) Mettre a jour le catalogue              |"<<endl;
	cout<<setw(70)<<"|                                                          |"<<endl;
	cout<<setw(70)<<"|              (3) Ajouter des clients                     |"<<endl;
	cout<<setw(70)<<"|                                                          |"<<endl;
	cout<<setw(70)<<"|              (4) Retour en arriere                       |"<<endl;
	cout<<setw(70)<<"|__________________________________________________________|"<<endl;
	cout<<"====================>>> Faite votre choix: "<<endl;
	cin>>ichoix2;
		}
	switch(ichoix2)
	{
	case 1:
		{
	voircatalogue(produits);
		}
	break;
	case 2:
		{
	ajoutitem(produits);
		}
	break;
	case 3:
		{
	ajoutclients(clients);
		}
	break;
	system("cls");
	case 4:
		{
	cout<<setw(70)<<"|^^^^^^^^^^^^^^^^Voici un magasin d'auto^^^^^^^^^^^^^^^^^^^|"<<endl;
	cout<<setw(70)<<"|                                                          |"<<endl;
	cout<<setw(70)<<"|              (1) Administrer mon magasin                 |"<<endl;
	cout<<setw(70)<<"|                                                          |"<<endl;
	cout<<setw(70)<<"|              (2) Faire un achat                          |"<<endl;
	cout<<setw(70)<<"|                                                          |"<<endl;
	cout<<setw(70)<<"|              (3) Quitter le programme                    |"<<endl;
	cout<<setw(70)<<"|__________________________________________________________|"<<endl;
	cout<<"====================>>> Faite votre choix: "<<endl;
	cin>>ichoix;
		}
	}
	break;
	case 2:
		{

		}	
	break;
	case 3:
		{
	cout<<">>>>>>>>>>>>>>>>>>>>>>>>>>>Au revoir!!!<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"<<endl;
	system("cls");
	system("pause");
	}
}
return 0;
}
void voircatalogue(fstream &produit)
{
cout<<"Lol";
}
void ajoutitem(fstream &produit)
{
	fstream FFproduits("Fproduits.dat", ios::in|ios::out|ios::binary);
	if ( !FFproduits)
	{
		cerr <<"Ouverture Impossible";
		exit(1);
	}
	produit unproduit;
	do
	{
	cout<<"Entrez le ID de l'item :"<<endl;
	cin>>unproduit.ID;
	cout<<"Entrez le nom de l'item :"<<endl;
	cin>>unproduit.nom;
	cout<<"Entrez la description de l'item :"<<endl;
	cin>>unproduit.description;
	cout<<"Entrez le prix de l'item :"<<endl;
	cin>>unproduit.prix;
	cout<<"Entrez le nombre en inventaire de l'item :"<<endl;
	cin>>unproduit.Nbinv;
	cout<<"Un autre produit(O\N) ?:"<<endl;
	cin>>rep;
	FFproduits.seekp((unproduit.ID-1) *sizeof(produit));
	FFproduits.write(reinterpret_cast<const char*>(&unproduit), sizeof(produit));
	}
	while (rep == 'n'||rep =='N');
}

tihs program isn't finished .. but yeah.. im stuck on those errors that make me unable to advance at all

just try to move ur struct declaration to be just sfter ur struct definition, that means ur struct declaration will be a global declaration coz it seems as if u are using it through-out the project, then u can assign the values to it by using the dot syntax which will somethig like unproduit.Id = 0; and so forth....

Will do thx.

Edit: .... Ewww 59Error now o.O

Will do thx.

Edit: .... Ewww 59Error now o.O

Dit2: NVM!! I got it!! Thx !!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.