title: Why is sizeof not returning the correct number of elements in array?
body: <p>So for practice, I wrote a little code that takes a variable number of integers in an array and then determines the largest value.</p>
  
  <p>I wanted to make the program runnable from the command line (i.e. <code>findMax 4, 5, 6, 20, 1, 3</code> in that exact format).</p>
  
  <p>So considering that <code>argv[1]</code> is a pointer to a <code>char</code> array, I figure I can loop from <code>argv[1][0]</code> to <code>argv[1][n]</code>.</p>
  
  <p>I think the pointers are the reason I am not able to get my code to work.<br>
  In the first code, I wrote, using</p>
  
  <pre><code>sizeof(arr) / sizeof(arr[0]) = # of elements in array 'arr'
  </code></pre>
  
  <p>correctly gave me the number of elements.<br>
  However, when I run</p>
  
  <pre><code>sizeof(argv[1]) / sizeof(argv[1][0]) = always return (integer) 4
  </code></pre>
  
  <p>Am I correct in thinking that I am using a pointer here, which is why the size is always the same? I tried to dereference both of them (separately and together) but it created even more confusing results.</p>
  
  <p>Here is the full code which is not working. <strong>Except</strong> for some odd reason, it only works when I enter exactly <strong>two</strong> numbers (i.e. findMax.exe 2, 3 will correctly determine that '3' is the largest number).</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  int main(int argc, char *argv[]) {
  
      printf ("Finding largest value from input: %s", argv[1]);
  
      int size = (int)sizeof(argv[1]) / (int)sizeof(argv[1][0]);
      int x = 0;
      int next;
      int biggest = 0;
  
      while (x &lt; size) {
          if (argv[1][x] != ',') {
              next = argv[1][x];
              printf("\n%c", (int)next);
              if ((int)next &gt; biggest) {
                  biggest = next;
              }   
          }
          x++;
      }
      printf("\nBiggest # is: %c", biggest);
  
      return 0;
  }
  </code></pre>