How to save a sentence in a text file in c++?
<p>This is what I have, this program runs ok as it stands, the only problem I am having is that it will not save the approriate sentence in File3.txt. I included the entire program for understanding, what is it that I am not doing correctly that is preventing the sentence under the case option 'r' to not save? Thanks.</p>

<pre><code>void ascii (int number);
bool raffle (int number);
const int cArray=5;




int main () 
{       

    int value;

    char option;

while (1)
{


    cout &lt;&lt;"Enter a positive integer number: " &lt;&lt;endl;
    cin &gt;&gt;value;
    cout &lt;&lt;endl;


    cout &lt;&lt;"A[scii]" "\t\tR[affle]" "\t\tE[xit]" &lt;&lt;endl;
    cout &lt;&lt;"Please select an option: " &lt;&lt;endl;
    cin &gt;&gt;option;
    cout&lt;&lt;endl;

    switch (option)
    {
        case 'a':
        case 'A':

            ascii(value);
            break;

        case 'r':
        case 'R':
            ofstream outfile("G:/File3.txt", ios::out);
            if(!outfile)
            {
                cout&lt;&lt;"File could not be opened"&lt;&lt;endl;
                exit(1);
            }
            if (raffle(value)==1)
            {
                outfile&lt;&lt;"The number "&lt;&lt;value&lt;&lt;"is present in the array."&lt;&lt;endl;
            }
            else
            {
                outfile&lt;&lt;"The number "&lt;&lt;value&lt;&lt;"is not present in the array."&lt;&lt;endl;
            }
            outfile.close();
            break;

        case 'e':
        case 'E':

            return 0;
            break;


    }
}
}


void ascii (int value)
{

    if (48 &lt;= value &amp;&amp; value &lt;= 57)
    {
        cout &lt;&lt;"The number you have entered corresponds to a digit in the ASCII table." &lt;&lt;endl;
    }
    else if(65 &lt;= value &amp;&amp; value &lt;= 90)
    {
        cout &lt;&lt;"The number you have entered corresponds to an uppercase letter in the ASCII table." &lt;&lt;endl;
    }
    else if (97 &lt;= value &amp;&amp; value &lt;= 122)
    {
        cout &lt;&lt;"The number you have entered corresponds to a lowercase letter in the ASCII table." &lt;&lt;endl;
    }
    else  
    {
        cout &lt;&lt;"The number you have entered corresponds to none of the above." &lt;&lt; endl;
    }

}

bool raffle (int value)
{   
    int random[cArray];
    srand(time(NULL));
    for (int i=0; i&lt;5; i++)
    {
        random[i]= 0+rand()%(100+1-0);
        cout&lt;&lt;random[i]&lt;&lt;" "&lt;&lt;endl;
    }

    for (int j=0; j&lt;5; j++)
    {
        if (value == random[j])
        {
            cout &lt;&lt; "\n" &lt;&lt;j&lt;&lt;endl;

            return true;
        }
    }
            cout &lt;&lt; "Number not present."&lt;&lt;endl;
            return false;



}
</code></pre>
