short *massTempOld = new short[*size]; for (short i = 0; i < *size; i++) massTempOld[i] = mass[i]; delete [] mass; (*size) += (*sizeTemp); short *mass = new short[*size]; for (short i = 0; i < *size; i++) { if (i < (*size - *sizeTemp)) mass[i] = massTempOld[i]; else mass[i] = massTemp[i]; } delete sizeTemp; delete [] massTemp; delete [] massTempOld; Before the switch, memory is allocated for the mass[size] array and generate elements. In one of the cases, I create an array of massTempOld[size] in which I write the elements mass[size] , then delete the memory delete[]mass and allocate memory for a given size larger (*size) += (*sizeTemp) → short *mass = new short[*size]; and write down there old + new items. After exiting the switch, the garbage from the mass[size] array is displayed on the screen. Tell me what the problem is. Thank!
delete sizeTemp;? Did you have a single variable in dynamic memory allocated? What for? What ismassTemp, where did it come from and what size does it have? - AnTunique_ptr<T[]>. Java and C # programmers were indignant. - Ariox