writing multiple arrays to a new array in a funciton

Like the question says, I am trying to write 2 to 3 arrays to a new array. I am currently writing a function where I am wanting to get new input from the user, write it to a temp array, and then copy that to a new array. I am able to do this but then I want to use another variable called into the function, and write that to the same new array that I also wrote to with the temp array. Can someone provide me with an example or help me out?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
int test(int a, int b, int c, string d[], string new[])
{
    string tempArr[SIZE]; // array I will get user input from
    string line;
    for (int i = 0; i < a; i++)
    {
        cout << "Please input a line of text." << endl;
        getline(cin, line);
        tempArr[i] = line;
        new[i] = tempArr[i]; // writing the temp array info to new array
    }

    for (int i = 0; i <= b; i++)
    {
        new[i] = d[i]; //write info in array d to the new array
    }
   
    for (int i = 0; i < (a+b); i++) // just using this to see what the input is
    {
        cout << new[i] << " " << endl; // wanting to save the arrays of a and d to new array
    }
    return 0;
}
Last edited on
Topic archived. No new replies allowed.