Passing fstream to a function
<p>I'm trying to pass an fstream to a function which then writes struct to the file. I'm aware that you have to pass the stream by reference, but nothing is being written to the file at runtime. Heres what I have so far:</p>

<pre><code>struct Record
{
    char name     [16];
    char phoneNum [16];
    float balance;
};

void newRec (fstream &amp;);

int main()
{
    fstream ref;
    ref.open("prog2.dat", ios::in | ios::out | ios::app | ios::binary);
    if(!ref.fail() )
    {
        int choice = menu(ref);
        system("CLS");

        while(choice != 6)
        {
            choice = menu(ref);
            system("CLS");
        }
    }
    else
        cout &lt;&lt; "Error opening file. " &lt;&lt; endl;

    return 0;
}


void newRec (fstream&amp; ref)
{   
    Record rec;

    cout &lt;&lt; "Enter customer name: ";
    cin.ignore();
    cin.getline(rec.name, sizeof(rec.name));
    cout &lt;&lt; "Enter customer phone number: ";
    cin &gt;&gt; rec.phoneNum;
    cout &lt;&lt; "Enter beginning account balance: ";
    cin &gt;&gt; rec.balance;

    ref.write(reinterpret_cast&lt;char*&gt;(&amp;rec), sizeof(rec));
} 
</code></pre>

<p>rec being just a 3 member struct. Any ideas why this wouldn't work? I appreciate any help.
Note: I do have to use .write() as opposed to &lt;&lt; as per my assignment</p>
