title: Reading a csv file using C and then doing string manipulation
body: <p>First I open a CSV file (<code>Cars.csv</code>) using my C file <code>cars.c</code>. My CSV file would look like:</p>
  
  <pre><code>toyota, 100, 20, 150.50  
  nissan, 200, 50, 100.75  
  BMW,    400, 80, 323.00
  </code></pre>
  
  <p>The 1st column is names, 2nd column is stock, 3rd column is order, 4th column is price.</p>
  
  <p>Then I have to do two works(I will call the program in the commandline with the work name and any other argument I need to pass): </p>
  
  <ol>
  <li><p>List all the items in the CSV file while the commas cannot be a part of the output. I also have to print headers for each column. (./cars list)</p></li>
  <li><p>I would send an argument when running the program from the command line. The argument would be one the name of the items in my csv file. Then I would have to subtract 1 from the stock and update the CSVfile. (./cars reduce nissan)</p></li>
  </ol>
  
  <p>This is how I opened the CSV file.    </p>
  
  <pre><code>void main(int argc, char *argv[]) {
  
  FILE *in = fopen ("Cars.csv" ,"rt");
  
  if (in == NULL) { 
    fclose (in); return 0; 
  }
  </code></pre>
  
  <p>//I need to store the data from the CSV file in an array of pointers. I know how to do that, but Im having a problem in storing them without the commas and then doing what I need to do in part 1.</p>
  
  <p>//This is the only code I could write for the 2nd part. </p>
  
  <pre><code>int p =0;
  for(p =0; p&lt;; p = p + 4) {
  
  
  if(strcmp(argsv[2],save[p]) == 0) {  //save is the array of pointers where I 
     int r = int(save[p +1]);           //store the data from the csv file
     int s = r - 1;
     char str[15];
     sprintf(str, "%d", s);
     save[p +1] = str; // not sure if this line actually makes sense
  }
  }
  </code></pre>