title: Convert Array of Dates into Integers
body: <p>I am using the C programming language. I currently have a two dimensional character array of dates in this format <em>"2010-05-01"</em>. I would like to convert each number into the integer data type and then store them in an integer array. The reason for this is because I need to have an single dimensional array of integers that I can then pass to a function by reference using pointers. </p>
  
  <p>Please see my current code below:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;math.h&gt;
  #include &lt;string.h&gt;
  
  int main()
  {
      float values[] = { //Contains 100 float literals }
      int i, j, size = sizeof(values)/sizeof(*values);
      char strings[][10] = {"2010-05-01", "2010-10-01" //Contains a total of 100 dates}
      int dates[size * 3];
  
      for (i = 0, j = 0; j &lt; size; ++i, ++j) {
          dates[i] = atoi(strtok(strings[j], "-"));
          dates[++i] = atoi(strtok(NULL, "-"));
          dates[++i] = atoi(strtok(NULL, "-"));
      }
  
      for (i = 0; i &lt; size; ++i)
          printf("%d\n", dates[i]);
      return 0;
  }
  </code></pre>
  
  <p>This code currently returns a bus error and I do not see why. I am a relative beginner, so sorry if I have done something silly. Any comments would be appreciated and thank you for your time.</p>