title: C++ How to pass command line argument to read txt file
body: <p>What I've been trying to do is...</p>
  
  <p>1) to read txt files by command line argument,</p>
  
  <p>2) to use strings in the txt files as arguments for the main method (or whatever method you need to invoke).</p>
  
  <p>For example, there are two txt files, one of which is named character.txt and the other match.txt.</p>
  
  <p>The contents of the files would be like this.</p>
  
  <p><strong>character.txt</strong> </p>
  
  <pre><code>//This comprises of six rows. Each of the rows has two string values
  Goku Saiyan
  Gohan Half_Saiyan
  Kuririn Human
  Piccolo Namekian
  Frieza villain
  Cell villain
  </code></pre>
  
  <p><strong>match.txt</strong></p>
  
  <pre><code>//This comprises of three rows, each of them is one string value
  Goku Piccolo
  Gohan Cell
  Kuririn Frieza
  </code></pre>
  
  <p>If I use those strings without using command line, I'd declare the strings in character.txt like this.</p>
  
  <pre><code>typedef string name; //e.g. Goku
  typedef string type; //e.g. Saiyan, Human, etc
  </code></pre>
  
  <p>Now I'm looking for how to read and send string values from txt files like the ones above, and to use them for functions inside the main method, ideally like this way.</p>
  
  <pre><code>int main(int argc,  char *argv)
  {
      for (int i = 1; i &lt; argc; i++) {
  
          String name = *argv[i]; //e.g. Goku
          String type = *argv[i]; //e.g. Saiyan, Human, etc
          String match = * argv[i]; //Goku Piccolo
          //I don't think any of the statements above would be correct.
          //I'm just searching for how to use string values of txt files in such a way
  
          cout &lt;&lt; i &lt;&lt; " " &lt;&lt; endl; //I'd like to show names, types or matchs inside the double quotation mark. 
      }
  }
  </code></pre>
  
  <p>Ideally, I'd like to invoke this method in this way.
  <img src="https://i.stack.imgur.com/lWyfs.png" alt="enter image description here"></p>
  
  <p><a href="http://www.cprogramming.com/tutorial/lesson14.html" rel="nofollow noreferrer">According to this web site.</a>, at least I understand it is possible to use command line arguments with C++, but I cannot find any more information. I'd appreciate if you'd give any advice on it.</p>
  
  <p>PS. I'm using Windows and Code Blocks.</p>