Hello,
I have a question. I am trying to code a function that will append two array.
Here is the code, all work but the value doesn't return well, why?
Code:#include <iostream> using namespace std; void CopyChaineSuite(char *&s1, char *s2); void main() { char cPrenom1[80] = "Me"; char cPrenom2[80] = "andYou"; CopyChaineSuite(cPrenom1, cPrenom2); cout << "Prenom #1 : " << cPrenom1 << endl; cout << "Prenom #2 : " << cPrenom2 << endl; }//Fin du main void CopyChaineSuite(char *&s1, char *s2) { char *ptrDebut = new char; char *p = ptrDebut; while(*s1 != '\0') *ptrDebut++ = *s1++; while(*s2 != '\0') *ptrDebut++ = *s2++; *ptrDebut = '\0'; s1 = p; }//Fin de CopyChaineSuite




Reply With Quote