I am coding some program that among many other operations have one that from the two unordered arrays makes one ordered and lists all the elements of these two arrays into that one specific, and so far I have been doing great, however I got stuck on trivial problem and the thing is I can’t find what the hell is wrong with this code( maybe, it’s because I’m so sleepy/tired/etc… Any help is appreciated.
template < typename T>
void meltTwoRustyArraysAndProduceShinyOne(const T* a, int na, const T* b, int nb, T*& c, int& nca
{
c = new T[nc=na+nb];
int ia = 0, ib =0, ic = 0;
while (ia<in || ib < nb )
c[ic++] = ia==na ? b[ib++] : b==nb ? a[ia++] : a[ia]<b[ib] ? a[ia++] : b[ib++];
}
Thanks in advance.
The part with “b==nb ? b[ia++]” is incorrect. Change it to “b==nb ? a[ia++]”