Merging Two Lists Together?

I have to input two lists and then merge them together that lists them in numeric order. I must use this formula within the code:

void merge(const int list1[], int size1, const int list2[], int size2, int list3[])


This is all I have so far:

#include <iostream>
#include <list>
using namespace std;

void merge(const int list1[], int size1, const int list2[], int size2, int list3[]); // function prototype

const int SIZE = 80;
int list1[SIZE];
int list2[SIZE];
int list3[SIZE];

int main()
{

cout << "Enter list1: ";
cin >> list1[SIZE];

cout << "Enter list2: ";
cin >> list2[SIZE];

merge(list1, SIZE, list2, SIZE, list3); // invoking the function

return 0;
}

void merge(const int list1[], int size1, const int list2[], int size2, int list3[]) // doing the function
{


}


Also, I was testing a part of my code, and it only lets me input up to 2 numbers for my first list, and then I can't input anything for my second list.

Any help is much appreciated! Thank you!
Last edited on
The first thing to realize is that you are only asking for 2 numeric inputs, so 2 numeric inputs is all you're going to get.

The second is that for an array (list1) of SIZE elements, valid indexes are 0 to SIZE-1. list1[SIZE] is not an element of list1, and using SIZE to index list1 is an error that results in undefined behavior.
Last edited on
To solve the first issue, how do I ask for more inputs? The maximum list size is 80. Would I say list1[79] and list2[79]?
To solve the first issue, how do I ask for more inputs?

By asking for input more than twice.

The maximum list size is 80. Would I say list1[79] and list2[79]?

Those would be the last elements in the array. You need to get input for each element of the array. Typically that would be done by looping SIZE times.
Topic archived. No new replies allowed.