Click to See Complete Forum and Search --> : How to copy one array to the end of another array?


pop
September 30th, 1999, 06:49 PM
Urgent! Thank you very much.

Ghosty
October 1st, 1999, 04:15 AM
First you get the length of both Arrays: short int thing[] = {1,2,3,4};
int length = sizeof thing / sizeof (short);
And then if had both lengths add both to one: lenght += length2;
And then create a new Array: int *array = new int [length];
And then copy both arrays into the one and to not forget to delete the both arrays
for (int i =0; i<=length; i++)
{ array[i]=thing[i];} and delete thing.

eric33
October 1st, 1999, 05:50 AM
The best method could be to use memcpy


int i[10];
int j[10];
memcpy( &i[10], j, sizeof(int)*10 );