Passing an array into a function

I'm trying to pass an array read from a file to a function. I'm getting an error message saying "no match for 'operator<<' in std::operator<<"

Here's my code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include <iostream>
#include <cstdlib>
#include <fstream>
#include <iomanip>
#include <string>

using namespace std;

double input2(double the_array[], int size);

void output2(double the_Array[], int size);

int main()

{

    double array2[15] = {0.0};

    input2(array2, 15);

    cout << "The numbers are: " << output2(array2, 15);

    return 0;

}

double input2(double the_array[], int size)
{
    string file_name, from_file;
    ifstream in_stream;

    cout << "Type a file name\n";
    cin >> file_name;

    in_stream.open(file_name.c_str());

    if ( in_stream.fail())
    {
      cout << "File opening failed\n";
      exit(1);
    }

    for (int i = 0; i < size; i++)
    {
        in_stream >> the_array [i];
    }

    in_stream.close();

}

void output2(double the_array[], int size )
{
    cout << "The numbers are: \n";

    for ( int i = 0; i < size; i++)
     {
         cout << the_array[i] << "\n";
     }


I'm just trying to take the array given from the input function and pass it to the output function. What am I doing wrong?
Function output2 is void. It doesn't return anything. Yet you are trying to print it (line 21).
Simply call it:
1
2
cout << "stuff";
output2(array2, 15);
Topic archived. No new replies allowed.