need help merging two arrays together using pointers! yikes i'm confused!
need help merging two arrays together using pointers! yikes i'm confused!
So am I. Merge them how? Are they sorted? Should the resulting array be sorted? Or do you want them interleaved, a[0], b[0], a[1], b[1]... regardless of sort order. Or do you just want to tack one on the end of the other, a[0]...a[n], b[0]...b[n]. Or something else entirely. Also, what do you mean by "using pointers"?
Note, if you're looking for a free answer, you wont get one here. However, if you show us your code so far, and explain more clearly where you're stuck, we will help you.
djwc77, are you talking about linked lists of statically allocated arrays?
If its two static arrays, you need to find how many elements are in both, make an array of that size and begin tossing elements into it from one. Otherwise, I'm pretty sure it's impossible to 'merge' two static arrays. Hence I think why you're using pointers.
Oh, are you allocating your arrays dynamically? Like,
?Code:int *x = malloc(number_of_elements*sizeof(*x));
In that case, I think you could do a realloc, right?
Either way, it's simple to insert a list inside another one but I think for dynamically allocated arrays, you'd need to allocate a new array or reallocate one of them.
If you store all your data in a list and store a reference to that data, then it's easy.
My homepage
Advice: Take only as directed - If symptoms persist, please see your debugger
Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"