Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

void merge with array

$
0
0
how to use VOID merge to merge array A and B? this program merge but i didnt use void merge and where should i put it , so can you help me to edit it ? thanks


#include <iostream>
#include <algorithm>
#include <iterator>

using namespace std;

int A[] = {1,2,3}, B[] = {4,5,6};
size_t A_len = sizeof(A) / sizeof(A[0]),
              B_len = sizeof(B)/> / sizeof(B[0]);
int *C = new int[A_len + B_len];

int main(int argc, char *argv[]) {
    // copy A to C
    copy(A, A + A_len, C);

    // append B to C
    copy(B, B + B_len, C + A_len);

    // display C
    copy(C, C + A_len + B_len, ostream_iterator<int>(cout, " "));
    cout << endl;

    // delete C
    delete [] C;

    return 0;
}

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>