<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: C++ Filestream in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/c-filestream/m-p/3876582#M98929</link>
    <description>// try it&lt;BR /&gt;// here is the code&lt;BR /&gt;&lt;BR /&gt;#include &lt;FSTREAM&gt;&lt;BR /&gt;#include &lt;STRING&gt; &lt;BR /&gt;#include &lt;STDIO.H&gt; &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;fstream fp1;&lt;BR /&gt;fstream fp2;&lt;BR /&gt;fstream temp;&lt;BR /&gt;boolean line_to_print=true;&lt;BR /&gt;  &lt;BR /&gt;string str_line_fp1;&lt;BR /&gt;string str_line_fp2;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;fp1.open ("Input1_File", fstream::out);&lt;BR /&gt;fp2.open ("Input2_File", fstream::out);&lt;BR /&gt;temp.open ("tempFile", fstream::in);&lt;BR /&gt; &lt;BR /&gt;while (fp2.good()) {&lt;BR /&gt;     &lt;BR /&gt;   fp2 &amp;gt;&amp;gt; str_line_fp2;&lt;BR /&gt;   &lt;BR /&gt;   while (fp1.good()) {&lt;BR /&gt;  &lt;BR /&gt;      fp1 &amp;gt;&amp;gt; str_line_fp1;&lt;BR /&gt;   &lt;BR /&gt;      // check if linefile2 is in file1&lt;BR /&gt;      if (str_line_fp2 == str_line_fp1)&lt;BR /&gt; &lt;BR /&gt;          line_to_print=false;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;   } //end wihle fp1&lt;BR /&gt;&lt;BR /&gt;   if (line_to_print == true) {&lt;BR /&gt;    &lt;BR /&gt;     temp &amp;lt;&amp;lt; str_line_fp2;&lt;BR /&gt;     temp.flush(); &lt;BR /&gt;&lt;BR /&gt;   }&lt;BR /&gt; &lt;BR /&gt;   line_to_print=true;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;} //end wihle fp2&lt;BR /&gt;&lt;BR /&gt;rename ("tempFile", "Input2_File"); &lt;BR /&gt;&lt;BR /&gt;// end&lt;/STDIO.H&gt;&lt;/STRING&gt;&lt;/FSTREAM&gt;</description>
    <pubDate>Tue, 10 Oct 2006 05:23:29 GMT</pubDate>
    <dc:creator>Leonardo_14</dc:creator>
    <dc:date>2006-10-10T05:23:29Z</dc:date>
    <item>
      <title>C++ Filestream</title>
      <link>https://community.hpe.com/t5/operating-system-linux/c-filestream/m-p/3876580#M98927</link>
      <description>I have to implement routine in C++ using fstream.&lt;BR /&gt;&lt;BR /&gt;Which wll take compare two file lets say Input1 and Input2.&lt;BR /&gt;It wll delete contents of Input1 from Input2 files.&lt;BR /&gt;&lt;BR /&gt;Can somebody suggest me a better idea of doing it, using fstream&lt;BR /&gt;&lt;BR /&gt;Input1 File&lt;BR /&gt;Hello how are you I am fine.&lt;BR /&gt;C++ world.&lt;BR /&gt;People in This forum is great. &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Input 2 file&lt;BR /&gt;I am doing fine &lt;BR /&gt;Wishing u all the best.&lt;BR /&gt;Hello how are you I am fine.&lt;BR /&gt;C++ world.&lt;BR /&gt;People in This forum is great. &lt;BR /&gt;Thanks for this program&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;When i run binary the contents of the file Input2 should be like&lt;BR /&gt;&lt;BR /&gt;Input2 file&lt;BR /&gt;I am doing fine &lt;BR /&gt;Wishing u all the best.&lt;BR /&gt;Thanks for this program&lt;BR /&gt;</description>
      <pubDate>Mon, 09 Oct 2006 04:17:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/c-filestream/m-p/3876580#M98927</guid>
      <dc:creator>Tnameh</dc:creator>
      <dc:date>2006-10-09T04:17:31Z</dc:date>
    </item>
    <item>
      <title>Re: C++ Filestream</title>
      <link>https://community.hpe.com/t5/operating-system-linux/c-filestream/m-p/3876581#M98928</link>
      <description>Note: There is no reason to use fstream, you should use stdio.&lt;BR /&gt;&lt;BR /&gt;In general, if the files aren't sorted, you'll need to keep file1 in memory so you don't need to re-read file1 for each line in file2.  You would then sort file1 and when reading file2, use a binary search to see if in file1.&lt;BR /&gt;&lt;BR /&gt;Alternately, you can add a new field to file2, containing the original order, sort it and file1 and then read the records, removing duplicates.  Then re-sort file2, and remove the extra field.</description>
      <pubDate>Mon, 09 Oct 2006 17:12:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/c-filestream/m-p/3876581#M98928</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2006-10-09T17:12:45Z</dc:date>
    </item>
    <item>
      <title>Re: C++ Filestream</title>
      <link>https://community.hpe.com/t5/operating-system-linux/c-filestream/m-p/3876582#M98929</link>
      <description>// try it&lt;BR /&gt;// here is the code&lt;BR /&gt;&lt;BR /&gt;#include &lt;FSTREAM&gt;&lt;BR /&gt;#include &lt;STRING&gt; &lt;BR /&gt;#include &lt;STDIO.H&gt; &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;fstream fp1;&lt;BR /&gt;fstream fp2;&lt;BR /&gt;fstream temp;&lt;BR /&gt;boolean line_to_print=true;&lt;BR /&gt;  &lt;BR /&gt;string str_line_fp1;&lt;BR /&gt;string str_line_fp2;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;fp1.open ("Input1_File", fstream::out);&lt;BR /&gt;fp2.open ("Input2_File", fstream::out);&lt;BR /&gt;temp.open ("tempFile", fstream::in);&lt;BR /&gt; &lt;BR /&gt;while (fp2.good()) {&lt;BR /&gt;     &lt;BR /&gt;   fp2 &amp;gt;&amp;gt; str_line_fp2;&lt;BR /&gt;   &lt;BR /&gt;   while (fp1.good()) {&lt;BR /&gt;  &lt;BR /&gt;      fp1 &amp;gt;&amp;gt; str_line_fp1;&lt;BR /&gt;   &lt;BR /&gt;      // check if linefile2 is in file1&lt;BR /&gt;      if (str_line_fp2 == str_line_fp1)&lt;BR /&gt; &lt;BR /&gt;          line_to_print=false;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;   } //end wihle fp1&lt;BR /&gt;&lt;BR /&gt;   if (line_to_print == true) {&lt;BR /&gt;    &lt;BR /&gt;     temp &amp;lt;&amp;lt; str_line_fp2;&lt;BR /&gt;     temp.flush(); &lt;BR /&gt;&lt;BR /&gt;   }&lt;BR /&gt; &lt;BR /&gt;   line_to_print=true;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;} //end wihle fp2&lt;BR /&gt;&lt;BR /&gt;rename ("tempFile", "Input2_File"); &lt;BR /&gt;&lt;BR /&gt;// end&lt;/STDIO.H&gt;&lt;/STRING&gt;&lt;/FSTREAM&gt;</description>
      <pubDate>Tue, 10 Oct 2006 05:23:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/c-filestream/m-p/3876582#M98929</guid>
      <dc:creator>Leonardo_14</dc:creator>
      <dc:date>2006-10-10T05:23:29Z</dc:date>
    </item>
    <item>
      <title>Re: C++ Filestream</title>
      <link>https://community.hpe.com/t5/operating-system-linux/c-filestream/m-p/3876583#M98930</link>
      <description>&lt;!--!*#--&gt;so you have to close files so as explained in the attachment file&lt;BR /&gt;&lt;BR /&gt;Ciauz ;)</description>
      <pubDate>Tue, 10 Oct 2006 05:33:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/c-filestream/m-p/3876583#M98930</guid>
      <dc:creator>Leonardo_14</dc:creator>
      <dc:date>2006-10-10T05:33:45Z</dc:date>
    </item>
    <item>
      <title>Re: C++ Filestream</title>
      <link>https://community.hpe.com/t5/operating-system-linux/c-filestream/m-p/3876584#M98931</link>
      <description>&amp;gt; so you have to close files&lt;BR /&gt;&lt;BR /&gt;Several problems with your fragment.  You are using fstream vs stdio.  :-)&lt;BR /&gt;&lt;BR /&gt;You open each file in the wrong mode.  You should NOT be calling flush, instead insert a '\n'.  Replace boolean by bool.  You need to call getline vs the string extracter.  And you should be calling pubseekoff and clear to rewind fp1.&lt;BR /&gt;&lt;BR /&gt;See attached.</description>
      <pubDate>Tue, 10 Oct 2006 17:49:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/c-filestream/m-p/3876584#M98931</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2006-10-10T17:49:42Z</dc:date>
    </item>
  </channel>
</rss>

