title: How to iterate over a string in C?
body: <p>Right now I'm trying this:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  int main(int argc, char *argv[]) {
  
      if (argc != 3) {
  
          printf("Usage: %s %s sourcecode input", argv[0], argv[1]);
      }
      else {
          char source[] = "This is an example.";
          int i;
  
          for (i = 0; i &lt; sizeof(source); i++) {
  
              printf("%c", source[i]);
          }
      }
  
      getchar();
  
      return 0;
  }
  </code></pre>
  
  <p>This does also NOT work:</p>
  
  <pre><code>char *source = "This is an example.";
  int i;
  
  for (i = 0; i &lt; strlen(source); i++){
  
      printf("%c", source[i]);
  }
  </code></pre>
  
  <p>I get the error</p>
  
  <blockquote>
    <p>Unhandled exception at 0x5bf714cf (msvcr100d.dll) in Test.exe: 0xC0000005: Access violation while reading at position 0x00000054.</p>
  </blockquote>
  
  <p>(loosely translated from german)</p>
  
  <p>So what's wrong with my code?</p>