title: Print memory addresses of chars in a string with (void*) cast
body: <p>I'm experimenting with bracket and pointer syntax in C++ to cement my understanding of each. Reading other StackOverflow questions, I'm aware that in order to print a memory address with <code>std::cout</code> I must cast the value using <code>(void *)</code>. I also saw recommendations to use <code>std::addressof</code>. My syntax in this question is strictly for learning and not representative of my notion of best practices.</p>
  
  <p>For a string "Hello, World" as <code>argv[1]</code>, I'm able to print the memory location of each character using the following:</p>
  
  <pre><code>  for (int i = 0; argv[1][i] != '\0'; i++) {
      std::cout &lt;&lt; "Letter: " &lt;&lt; argv[1][i] &lt;&lt; " Address: " &lt;&lt; (void*)&amp;argv[1][i] &lt;&lt; std::endl;
    }
  </code></pre>
  
  <p>I would expect the same outcome using this notation:</p>
  
  <pre><code>for (char *c = argv[1]; *c != '\0'; c++) {
      std::cout &lt;&lt; "Letter: " &lt;&lt; *c &lt;&lt; " Address: " &lt;&lt; (void*)&amp;c &lt;&lt; std::endl;
    }
  </code></pre>
  
  <p>However, I get the following output:</p>
  
  <pre><code>Letter: H Address: 0x7ffee4e05788
  Letter: e Address: 0x7ffee4e05788
  Letter: l Address: 0x7ffee4e05788
  Letter: l Address: 0x7ffee4e05788
  Letter: o Address: 0x7ffee4e05788
  Letter: , Address: 0x7ffee4e05788
  Letter:   Address: 0x7ffee4e05788
  Letter: W Address: 0x7ffee4e05788
  Letter: o Address: 0x7ffee4e05788
  Letter: r Address: 0x7ffee4e05788
  Letter: l Address: 0x7ffee4e05788
  Letter: d Address: 0x7ffee4e05788
  </code></pre>
  
  <p>My understanding is that...</p>
  
  <ul>
  <li>c is a pointer to a char</li>
  <li>*c is the value of the pointee</li>
  <li>&amp;c is the memory address held by the pointer</li>
  <li>c++ increments c to the memory address of the next char</li>
  </ul>
  
  <p>So, I should see a unique memory address printed for each char. What might explain this outcome?</p>