title: Comand line argument to variable as integer
body: <p>I have a function with width currently defined as "unsigned long width" and then define it as "width = 16".</p>
  
  <p>Instead, I'd like 16 to be the default number, but I want there to be an option to set a different integer for width with the command line when started.</p>
  
  <p>Command could be /program command -width 100 filename</p>
  
  <p>I've tried to do this as following but it does not compile and I'm not able to debug it successfully.
  Main is set to int main(int argc, char *argv[]).</p>
  
  <p>my attempt</p>
  
  <pre><code>void process_file(FILE *infile,unsigned long end)
  {
      char ch;
      int width,start,f_index=0;   //File index
      unsigned long bb_index=0;  // Buffer index
      //width =16; // Width is fixed as 16
      if((argc == 5) &amp;&amp; (strcmp(argv[2],"-width") == 0))
      {
          width = atoi(argv[3]);
      }
      else
      {
          width = 16;
      }
      unsigned char *byte_buffer = malloc(width);
      start=0; // Starting at zero
      while (!feof(infile))
      {
          ch = getc(infile);
          if ((f_index &gt;= start)&amp;&amp;(f_index &lt;= end))
          {
              byte_buffer[bb_index] = ch;
              bb_index++;
          }
          if (bb_index &gt;= width)
          {
              print(byte_buffer,bb_index,width);
              bb_index=0;
          }
      }
  </code></pre>
  
  <p>original function with defined (static) width which works, but does not read argv[3]</p>
  
  <pre><code>void process_file(FILE *infile,unsigned long end)
  {
      char ch;
      unsigned long width,start,f_index=0;   //File index
      unsigned long bb_index=0;  // Buffer index
      width =16; // Width is fixed as 16
      unsigned char *byte_buffer = malloc(width);
      start=0; // Starting at zero
      while (!feof(infile))
      {
          ch = getc(infile);
          if ((f_index &gt;= start)&amp;&amp;(f_index &lt;= end))
          {
              byte_buffer[bb_index] = ch;
              bb_index++;
          }
          if (bb_index &gt;= width)
          {
              print(byte_buffer,bb_index,width);
              bb_index=0;
          }
          f_index++;
      }
      if (bb_index)
          print(byte_buffer,bb_index,width);
      fclose(infile);
      free(byte_buffer);
  }
  </code></pre>