A program that will correct a C++ program that has errors in the operator
<p>Write a program that will correct a C++ program that has errors in which operator, <code>&lt;&lt;</code> or <code>&gt;&gt;</code>, it uses with <code>cin</code> and <code>cout</code>. The program replaces each (incorrect) occurrence of</p>

<p><code>cin &lt;&lt;</code>
with the corrected version
<code>cin &gt;&gt;</code></p>

<p>and each (incorrect) occurrence of
<code>cout &gt;&gt;</code>
with the corrected version
<code>cout &lt;&lt;</code></p>

<p>Allow for the possibility that there may be any number of whitespace characters (one or more) between <code>cin</code> and <code>&lt;&lt;</code> and between <code>cout</code> and <code>&gt;&gt;</code>. The replacement corrected version has only one blank between the <code>cin</code> or <code>cout</code> and the following operator.</p>

<p>Your program should get the source filename as an input from the user. The corrected version should be output to a file with name <code>corrected.txt</code> and it should also be displayed on the terminal. That means output of your program (after getting the filename) should be exactly same as the contents of the file <code>corrected.txt</code>. Your program should define a function that is called with the input- and output-file streams as arguments.</p>

<p>There are no compile errors for the code. However, the code output's nothing (The file exists).  Also the words in the file will disappear after I compile the program. Can anyone give me some advice? Thanks!</p>

<pre><code>#include &lt;stdio.h&gt;
#include &lt;iostream&gt;
#include &lt;iomanip&gt;
#include &lt;cctype&gt;
#include &lt;fstream&gt;
#include &lt;string&gt;
using namespace std;

void print(ifstream&amp; input,ofstream&amp; output, char next)
{

    input.get(next);
    cout &lt;&lt; next;
    output.put(next);

    while(input &gt;&gt; next)
    {
        if(next=='c')
        {
            output.put(next);
            cout &lt;&lt; next;
            input.get(next);

            if(next=='i')
            {   output.put(next);
                cout &lt;&lt; next;
                input.get(next);


                if(next=='n')
                {
                    output.put(next);
                    cout &lt;&lt; next;
                    while(next==' ')
                    {
                        input.get(next);
                    }
                    output.put(' ');
                    if(next=='&lt;')
                    {

                        input.get(next);

                        if(next == '&lt;')

                        {
                            cout &lt;&lt; "&gt;&gt;";
                            input.get(next);

                        }
                        else
                        {
                            output.put(next);
                            cout &lt;&lt; next;
                        }
                    }
                    else
                    {
                        output.put(next);
                        cout &lt;&lt; next;
                    }
                }

                else
                {
                    output.put(next);
                    cout &lt;&lt; next;
                }
            }

            else if (next=='o')
            {
                output.put(next);
                cout &lt;&lt; next;
                input.get(next);

                if(next=='u')
                {
                    output.put(next);
                    cout &lt;&lt; next;
                    input.get(next);


                    if(next=='t')
                    {
                        output.put(next);
                        cout &lt;&lt; next;
                        while(next==' ')
                        {
                            input.get(next);
                        }
                        output.put(' ');
                        if(next=='&gt;')
                        {

                            input.get(next);

                            if(next == '&gt;')

                            {
                                cout &lt;&lt; "&lt;&lt;";
                                input.get(next);

                            }
                            else
                            {
                                output.put(next);
                                cout &lt;&lt; next;
                            }

                        }
                        else
                        {
                            output.put(next);
                            cout &lt;&lt; next;
                        }

                    }
                    else
                    {
                        output.put(next);
                        cout &lt;&lt; next;
                    }
                }

                else
                {
                    output.put(next);
                    cout &lt;&lt; next;
                }
                input.get(next);
            }

        }

    }
}

int main()
{
    ifstream input;
    ofstream output;
    char next;
    char filename[16];
    cout &lt;&lt; "Enter filename:" &lt;&lt; endl;
    cin &gt;&gt; filename;
    input.open(filename);
    if(input.fail()) {
        cout &lt;&lt; "Could not open the file " &lt;&lt; endl;
        exit(0);
    }
    output.open("original.txt");

    if (output.fail()) {
        cout &lt;&lt; "Could not open the file " &lt;&lt; filename &lt;&lt; endl;
        exit(1);
    }
    print(input, output, next);

    input.close();
    output.close();

    return 0;
}
</code></pre>