Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Take a look at this solution for your problem, I suggest to you to use stl sort algorithm for sort the output and struct for store data.</p> <pre><code>#include &lt;algorithm&gt; #include &lt;string&gt; #include &lt;vector&gt; #include &lt;iostream&gt; #include&lt;fstream&gt; using namespace std; #define MAX 1005 struct record{ string A,B,C,D; record(string A, string B, string C, string D) : A(A), B(B), C(C), D(D) {} bool operator &lt; (const record&amp; o) const { string tmp1 = A + " " + B + " " + C + " " + D; string tmp2 = o.A + " " + o.B + " " + o.C + " " + o.D; return (tmp1 &lt; tmp2); } }; int main() { string A,B,C,D; vector&lt;record&gt; my_vect; vector&lt;record&gt;::iterator it; ifstream inFile; inFile.open("test1.rtf"); while(inFile &gt;&gt; A &gt;&gt; B &gt;&gt; C &gt;&gt; D) { if(B == "OUT:") my_vect .push_back( record(A,B,C,D) ); } inFile.close(); sort(my_vect.begin(), my_vect.end()); ofstream outFile; outFile.open("test2.rtf"); for(it = my_vect.begin(); it != my_vect.end(); ++it) { outFile &lt;&lt; (*it).A &lt;&lt; " " &lt;&lt; (*it).B &lt;&lt; " " &lt;&lt; (*it).C &lt;&lt; " " &lt;&lt; (*it).D &lt;&lt; endl; } outFile.close(); return 0; } </code></pre> <p>The output for this algo is:</p> <pre><code>15:39:32 OUT: "RS5K_700.EXE" CONHorodeski@ALNWSPCNTRCTR1 15:40:10 OUT: "RS5K_700.EXE" CONHorodeski@ALNWSPCNTRCTR1 15:40:31 OUT: "RS5K_700.EXE" CONHorodeski@ALNWSPCNTRCTR1 15:47:10 OUT: "RS5K_700.EXE" SYSTEM@ALNWSPCNTRCTR1 16:07:48 OUT: "RS5K_700.EXE" CONHorodeski@ALNWSPCNTRCTR1 16:10:15 OUT: "RS5K_700.EXE" CONHorodeski@ALNWSPCNTRCTR1 17:01:49 OUT: "RS500.EXE" mlulchak@alnsvpmillterm 9:30:28 OUT: "RS5K_700.EXE" CONHorodeski@ALNWSPCNTRCTR1 </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload