title: Pass path to file / filename as argument to a function that prints the file to screen in C++
body: <p>As the title says, is there any way to pass the path to the file / filename to open as an argument in the function?</p>
  
  <p>I've written a short code for printing a .txt-file to the screen in C++, but instead of having all the code in the main(), I'd rather have it as an own function that I can call with the filename of the file to open as the only input argument.</p>
  
  <p>Basically the beginning of the function would look like</p>
  
  <pre><code>void printFileToScreen()
  {
   ifstream fin;
   char c; 
   fin.open("FILE_TO_OPEN.txt", ios::in);
  
  blablabla
  }
  </code></pre>
  
  <p>Now is there any way to pass "FILE_TO_OPEN.txt" when I call the function?</p>
  
  <p>I've tried </p>
  
  <pre><code>void printFileToScreen(string str)
  {
   ifstream fin;
   char c; 
   fin.open(str, ios::in);
  blablabla
  }
  </code></pre>
  
  <p>where I call the function like <code>printFileToScreen("FILENAME.txt")</code>, but with no luck, so I'm not sure how to do this. </p>
  
  <p>Hope anyone can help :)</p>