title: Access Last Element of Array
body: <p>I'm trying to access the last element in an array in C++ (more specifically, I'm trying to convert an integer into a character array and then access the last digit).  Here's what I've come up with so far:</p>
  
  <pre><code>int number_to_convert = 1234;
  char * num_string;
  sprintf(num_string, "%d", number_to_convert);
  printf("Number: %d Sizeof num_string: %d Sizeof *num_string: %d Sizeof num_string[0]: %d\n", number_to_convert, sizeof(num_string), sizeof(*num_string), sizeof(num_string[0]));
  </code></pre>
  
  <p>Using this info I tried several different combinations to access the last element:</p>
  
  <pre><code>num_string[sizeof(number_to_convert)/sizeof(*number_to_convert)-1];
  num_string[sizeof(number_to_convert)-sizeof(char)]
  </code></pre>
  
  <p>Maybe there's a better way to get the last digit, but this is the best way I could find.  I want the last character (not the null character).</p>