title: How to save a specific column into an array in C++?
body: <p>I have a set of data in a .txt file that has an arbitrary number of columns, specified by the user in the input. I want to read that file, pick one of the columns and save it in an array. What is the best way to do this?</p>
  <p>I have read <a href="https://stackoverflow.com/questions/40348550/store-a-txt-file-columns-into-an-array-in-c">this</a>, <a href="https://stackoverflow.com/questions/7868936/read-file-line-by-line-using-ifstream-in-c">this</a> and <a href="https://stackoverflow.com/questions/36673337/reading-text-file-and-storing-columns-in-an-array/36673540">this</a>, but they all establish in the code the specific number of columns. I want it to be some input, so that the code is &quot;general&quot; and saves in that array the specific column from the input. Thank you!</p>
  <p>EDIT: This is an example of how the input looks like - the total number of Columns (particles) is specified by the user. The output will be some other .txt of data coming from this one.</p>
  <pre><code>TIME     PART1       PART2       PART3       PART4  
  0    0.0147496  934.902 0.0949583   -1192.37    0.0141576   950.604 0.0905118   -1074.44    
  1.66667e-005    0.0147497   2804.7  0.0949583   -3577.12    0.0141576   2851.81 0.0905117   -3223.33    
  3.33333e-005    0.0147497   4674.5  0.0949582   -5961.86    0.0141577   4753.02 0.0905116   -5372.21    
  5e-005  0.0147498   6544.3  0.094958    -8346.6 0.0141578   6654.22 0.0905115   -7521.09    
  6.66667e-005    0.01475 8414.09 0.0949578   -10731.3    0.0141579   8555.41 0.0905114   -9669.96
  </code></pre>