title: Try catch exception handling C++
body: <p>I have just started with exception handling in C++ using <code>try</code> and <code>catch</code> blocks. I have a text file with some data and I am reading this file using <code>ifstream</code> and <code>getline</code> as shown below,</p>
  
  <pre><code>ifstream file;
  file.open("C:\\Test.txt", ios::in);
  string line;
  string firstLine;
  if (getline(file, line, ' '))
  {
      firstLine = line;
      getline(file, line);
  }
  </code></pre>
  
  <p>I would like to know how to implement exception handling in case <code>file.open</code> fails to open the specified file because it does not exist in the given path, for example there is no <code>Test.txt</code> in <code>C:</code></p>