title: How to extract this information
body: <p>I have come across questions of this type so many times in C++ that I felt it's about time I learn this technique. I know how it's done in Java, but I'm still a novice in C++.</p>
  
  <p>Suppose I have a text file which contains some dates in this format:</p>
  
  <pre><code>May 3rd, 2014, /
  December 4th, 2011, -
  January 19th, 200, -
  January 1st, 2011, /
  March 3rd, 1900, /
  </code></pre>
  
  <p>The last char in each line is like a date separator as shown below.</p>
  
  <p>How can I convert them to this format and write in another text file:</p>
  
  <pre><code>5/3/2014
  12-4-2011
  01-19-200
  1/1/2011
  03/03/1900
  </code></pre>
  
  <p>The focus here is on string manipulation and not file IO.</p>
  
  <p>My try:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;fstream&gt;
  #include &lt;string&gt;
  
  using namespace std;
  
  int main() {
      ifstream in;
      string s;
      cout &lt;&lt; "\nPlease enter the input file name\n";
      cin &gt;&gt; s;
      in.open(s);
      if (in) {
          // Logic goes here
      }
      else {
          cout &lt;&lt; "\nCouldn't locate the file.\n";
      }
      cin.get(); 
      return 0;
  }
  </code></pre>