Erreur : impossible de convertir de 'const char [17]' en 'char'
bonjour,
j'ai essayé ce code
Att_produit.cpp
Code:
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
|
#include "Att_produit.h"
#include <iostream>
using namespace std;
#include<string>
#include <cstring>
void init_prod_fab(tab_prod_fab &e)
{
string s1,s2;
char c1[]="BONJOUR";
const char *c2="";
s1=c1;
cout<<s1<<endl;
s2="AU REVOIR";
c2=s2.c_str();
cout<<c2<<endl;
string s="Machine à laver";
char c[30]="Machine à laver";
*e.Nom_prod = "Machine à laver";
//e.dure_fabric[]= "Machine à laver";
//cout<<"le nom du produit : "<< e.dure_fabric;
}
void saisir_prod_fab(tab_prod_fab &e)
{ int b;
cout<<"Tapez le nom du produit : "; cin>>e.Nom_prod;
cout<<"Tapez la durée de fabrication en heure: "; cin>>e.dure_fabric;
b = strlen(e.dure_fabric);
e.dure_fabric[b]+='h';
e.dure_fabric[b+1]+='\0';
//cout<<"la logneur de la chaine est : "<< b;
//cout<<"la durée est :"<< e.dure_fabric;
cout<<"Tapez l'état du stock : "; cin>>e.Etat_stok;
e.Quantit_fab=0; // initialement la quantité de fabrication égale à 0 avant une commande;
}
void affiche_prod_fab(tab_prod_fab e)
{
cout<< e.Nom_prod <<" "<< e.dure_fabric <<" " << e.Etat_stok <<" "<< e.Quantit_fab<<endl;
} |
le fichier Att_produit.h
Code:
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
|
#ifndef Att_produit_H
#define Att_produit_H
/*
struct tab_prod_fab
{
string Nom_prod,dure_fabric; // le nom du produit et durré de fabrication du produit
int Etat_stok; // nombre de produit en stock
int Quantit_fab; //Quantité à fabriqué ce qu'il reste a fabriqué pour le client (quantité demandé état de stock)
};
*/
struct tab_prod_fab
{
char *Nom_prod;
char dure_fabric[30]; // le nom du produit et durré de fabrication du produit
int Etat_stok; // nombre de produit en stock
int Quantit_fab; //Quantité à fabriqué ce qu'il reste a fabriqué pour le client (quantité demandé état de stock)
};
void init_prod_fab(tab_prod_fab &e);
void saisir_prod_fab(tab_prod_fab &e);
//Permet de saisir un produit qui peut être fabriqué par l'entreprise
void affiche_prod_fab(tab_prod_fab e);
//Permet d'afficher un employé
#endif |
tableau.cpp
Code:
1 2 3 4 5 6 7 8
|
#include "tableau.h"
#include <iostream>
using namespace std;
void tableau::insertion( tab_prod_fab p)
{saisir_prod_fab(p);
} |
tableau.h
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
|
#ifndef TABLEAU_H
#define TABLEAU_H
#include "Att_produit.h"
class tableau
{
public:
int i,j;
int t[20];
tab_prod_fab *tab_prod;
void insertion(tab_prod_fab P);
};
#endif |
main.cpp
Code:
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
|
#include <iostream>
using namespace std;
#include "tableau.h"
#include "Att_produit.h"
#include<string>
#include <cstring>
/*int tab(int x)
{
cout <<" la nombre x est: "<< x << endl;
return(x);
}
*/
int main()
{
tableau a;
//if (a.tab_prod!=NULL ) affiche_prod_fab(*a.tab_prod);
//cout <<"l'adresse du tableau " <<a.tab_prod<< endl;
a.tab_prod = new tab_prod_fab[5];
//cout <<"l'adresse du tableau " <<a.tab_prod<< endl;
////////////////////////////////initialisation du produit;
init_prod_fab(*a.tab_prod);
saisir_prod_fab(*a.tab_prod);
a.tab_prod++;
///////////////////////////////// affichage des produit
for (int i=0;i<2;i++)
{a.tab_prod--;
affiche_prod_fab(*a.tab_prod);
}
//////////////////////////////// libération de la mémoire occupé
delete [] a.tab_prod;
return 0;
} |
mais a chaque fois que je compile il m'affiche l'erreur suivant:
Erreur 1 error C2440: '='*: impossible de convertir de 'const char [17]' en 'char' att_produit.cpp 20
avec cette ligne de code:
Code:
1 2
|
*e.Nom_prod = "Machine à laver"; |
je ne sais si avec le probléme de appel de la méthode par référence j'ai tout les possiblité mais j'ai pas pu,
comment régler ce soucis
Merci