title: C++ open a file as read-only
body: <p>I have written a program which opens a file then displays line by line its contents (text file)</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;fstream&gt;
  #include &lt;string&gt;
  using namespace std;
  
  int main (int argc, char* argv[])
  {
      string STRING;        
      ifstream infile;    
      infile.open(argv[1]);   
      if (argc != 2)  
      {
          cout &lt;&lt; "ERROR.\n";
          return 1;
      }
      if(infile.fail())
      {
          cout &lt;&lt; "ERROR.\n";
          return 1;
      }
      else
      {
          while(!infile.eof())
          {
              getline(infile,STRING); 
              cout&lt;&lt;STRING + "\n"; 
          }   
          infile.close(); 
          return 0; 
      }
  }
  </code></pre>
  
  <p>What do I need to add to make the file be read only ?</p>
  
  <p>(<code>infile.open(argv[1])</code> is where am guessing something goes)</p>