i have the following code that looks just fine for me my intention is to swap the two structures name's and cne's but the "echange" function doesn't look like doing anything this the code that i wrote :
#include <iostream>
using namespace std;
struct etudiant{
char* nom ;
int cne ;
};
void echanger(etudiant khalil,etudiant ait){
etudiant *pt;
pt = &khalil ;
char* n ;
int p ;
n = ait.nom ;
p = ait.cne ;
ait.cne = pt->cne ;
ait.nom = pt->nom ;
khalil.cne = p;
khalil.nom = n;
}
int main(){
etudiant khalil ;
etudiant ait ;
khalil.cne = 123 ; khalil.nom = "khalil" ;
ait.cne = 789 ; ait.nom = "ait" ;
cout << "khalil : nom => " << khalil.nom << " ; cne => " << khalil.cne << endl;
cout << "ait : nom => " << ait.nom << " ; cne => " << ait.cne << endl;
echanger(khalil,ait);
cout << "khalil => nom : " << khalil.nom <<" ,cne : " << khalil.cne << endl;
cout << "ait => nom : " << ait.nom <<" ,cne : " << ait.cne << endl;
return 0;
}