public void LinkedList::add(char* element) { int elemSize = strlen(element); char **tabCPY = new char*[Size]; //On copie la table for(int i=0; i < iSize ; i++) { tabCPY[i] = new char[strlen(this->Tab[i])]; strcpy(tabCPY[i],this->Tab[i]); } //On libere la table for(int i=0; i < iSize ; i++) delete this->Tab[i]; delete this->Tab; //On la remonte avec une case en plus this->Size++; this->Tab = new char*[Size]; for(int i=0; i < iSize ; i++) { this->Tab[i] = new char[strlen(tabCPY[i])]; strcpy(this->Tab[i],tabCPY[i]); } //et on ajoute l element this->Tab[this->Size] = new char*[elemSize]; strcpy(this->Tab[this->Size - 1],element); //et on libere notre table de copy for(int i=0; i < iSize ; i++) delete tabCPY[i]; delete tabCPY; }
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question