Call by reference-stream and char in c++
<p>My latest homework assignment is to write a program that reads a textfile and outputs the number of lines, words and characters.</p>

<p>I'm just starting out, all I'm trying to do right now is to let the user type in the file name and then the file will open. This is my not-working code, I must be missing something obvious, I'm just trying to pass the stream and char to the 'input' function. </p>

<p>Any pointers?</p>

<pre><code>#include &lt;iostream&gt;
#include &lt;fstream&gt;
#include &lt;cstdlib&gt;
using namespace std;

//Define functions.
void input(ifstream&amp; fin, char&amp; fileName);

int main()
{
    ifstream fin;
    char fileName[20];
    input(fin, fileName);
    return 0;
}

void input(ifstream&amp; fin, char&amp; fileName)
{
    cout &lt;&lt; "Input file name: ";
    cin &gt;&gt; fileName;
    fin.open(fileName);

    if(fin.fail())
    {
        cout &lt;&lt; "The file:  " &lt;&lt; fileName &lt;&lt; " does not open." &lt;&lt; endl;
        exit(1);
    }
    //return;
}
</code></pre>
