How to read the string into a file C++
<p>i have a little problem on writing the string into a file,
How can i write the string into the file and able to view it as ascii text?
because i am able to do that when i set the default value for str but not when i enter a str data
Thanks.</p>

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

int main()
{
    fstream out("G://Test.txt");

    if(!out) {
        cout &lt;&lt; "Cannot open output file.\n";
        return 1;
    }
    char str[200];
    cout &lt;&lt; "Enter Customers data seperate by tab\n";
    cin &gt;&gt; str;
    cin.ignore();
    out.write(str, strlen(str));
    out.seekp(0 ,ios::end);
    out.close();

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