I have 2 arrays with coordinates and i want to copy them into one array. I used 2 for loops and its working, but i want to know, if i could do it without them, i dont know how to use memcpy in this situation. Here is my code:
int *join(int *first, int *second,int num, int size) {
int *path= NULL;
int i = 0 , j = 0;
path = (int*) malloc (2*size*sizeof(int));
for(i = 0 ; i < num; i++) {
path[i * 2] = first[i * 2];
path[i * 2 + 1] = first[i * 2 + 1];
}
for(i = num; i < size ; i++) {
path[(i*2)] = second[(j+1)*2];
path[(i*2)+1] = second[(j+1)*2 +1];
j++;
}
return path;
}