title: How do you get a file in C++?
body: <p>So the teacher has posed this assignment:</p>
  
  <p>You have been hired by the United Network Command for Law Enforcement, and you have been given files containing null cyphers you have to decrypt.</p>
  
  <p>So for the first file given (as an example), every other letter is correct (ie: 'hielqlpo' is hello (assuming you start with the first letter).  My first question is, how do I read in a file?  The document is on my desktop in a folder and the file is named document01.cry.  I'm not sure the command I need to put that file into the program.</p>
  
  <p>I'm also not overly sure how to grab a letter and skip a letter, but honestly I want to tinker with that before I post that question! So for now...my question is as stated in the title: How do you grab a file for reading in C++? </p>
  
  <p>If it makes a difference (As I'm sure it does), I'm using Visual C++ 2008 Express Edition (because it's free and I like it! I've also attached what I have so far, please keep in mind it's -very- basic...and I added the <code>getchar();</code> at the end so when it does run properly, the window stays open so I can see it (as Visual Express tends to close the window as soon as it's done running.)</p>
  
  <p>The code so far:</p>
  
  <pre><code>#include&lt;iostream&gt;
  
  using namespace std;
  
  int main()
  {
      while (! cin.eof())
      {
          int c = cin.get() ;
          cout.put(c) ;
      }
      getchar();
  }
  </code></pre>
  
  <p>PS: I realize that this code grabs and puts out every character. For now that's fine, once I can read in the file I think I can tinker with it from there.  I'm also poking at a book or two I have on C++ to see it anything pops up and screams "Pick me!" Thanks again!</p>
  
  <p>EDIT:: Also curious, is there a way to input the file you want?
  (I.e.:</p>
  
  <pre><code>char filename;
  cout &lt;&lt; "Please make sure the document is in the same file as the program, thank you!" &lt;&lt; endl &lt;&lt; "Please input document name: " ;
  cin &gt;&gt; filename;
  cout &lt;&lt; endl;
  ifstream infile(filename, ios::in);
  </code></pre>
  
  <p>This code doesn't work. It shoots back an error saying the char can't be converted to a const char *.  How can this problem be fixed?</p>
  
  <p>EDIT 2:
  Never mind about said part 2, I found it out! Thanks again for the assistance!</p>