title: Check whether file name already exists in a folder or not?
body: <p>In C++ I need to check whether a entered file name exists in that folder or not. I'm writing code for Linux, using the g++ compiler.
  please help guys :)</p>
  
  <p>I saw this code somewhere on net for my problem but I strongly feel it wont serve my purpose:</p>
  
  <pre><code>ofstream fout(filename);
  if(fout)
  {
  cout&lt;&lt;"File name already exists";
  return 1;
  }
  </code></pre>