removing or ignoreing duplicate lines from txt file C++
<p>currently i am trying to read a text file and ignore the duplicate lines inside it. Here's the code sample of what i have done so far</p>

<pre><code>string filename;
            cout&lt;&lt;"Please enter filename: "&lt;&lt;endl;
            cin&gt;&gt;filename;
            ifstream inFile(filename.data());

            typedef std::map&lt;std::string, int&gt; line_record;
            line_record lines;
            int line_number = 1;

            if(inFile.is_open())
            {
                while(std::getline(inFile, line))
                {   
                    line_record::iterator existing = lines.find(line);
                    if(existing != lines.end())
                    {
                        existing-&gt;second = (-1);
                    }
                    else
                    {
                        lines.insert(std::make_pair(line,line_number));
                        ++line_number;
                        getline(inFile,line);
                        cout&lt;&lt;line&lt;&lt;endl;
                        noOfLine++;    
                    }

                }    
            }else
            {
                cout&lt;&lt;"Error opening file! Please try again!"&lt;&lt;endl;
            }
            cout&lt;&lt;"\n"&lt;&lt;noOfLine&lt;&lt;" record(s) read in successfully!\n"&lt;&lt;endl;
</code></pre>

<p>The text file(below):</p>

<pre><code>Point2D, [3, 2]
Line3D, [7, 12, 3], [-9, 13, 68]
Point3D, [1, 3, 8]
Line2D, [5, 7], [3, 8]
Point2D, [3, 2]
Line3D, [7, -12, 3], [9, 13, 68]
Point3D, [6, 9, 5]
Point2D, [3, 2]
Line3D, [70, -120, -3], [-29, 1, 268]
Line3D, [25, -69, -33], [-2, -41, 58]
Point3D, [6, 9, -50]
</code></pre>

<p>But the results i am getting is:</p>

<pre><code>Line3D, [7, 12, 3], [-9, 13, 68]
Line2D, [5, 7], [3, 8]
Point3D, [6, 9, 5]
Line3D, [25, -69, -33], [-2, -41, 58]
Point3D, [6, 9, -50]
</code></pre>

<p>Any help?? Thanks!!</p>
