title: Why does Visual Studio output this in my C++ program (adding string and character)?
body: <p>I have been just reading the book <a href="http://www-f9.ijs.si/%7Estuden/literatura/Stroustrup_book.pdf" rel="nofollow noreferrer">The C++ Programming Language</a> by Bjarne Stroustrup. On the page 105, I tried the exercise 12 and I came to one (for me) crazy thing. After this, I managed to successfully solve the exercise, but I am interested, how and why does this happen? Here is the minimized code (only with this specific case):</p>
  <pre class="lang-cpp prettyprint-override"><code>int main()
  {
      char c;
      std::cin &gt;&gt; c;
      std::cout &lt;&lt; &quot;&quot; + c;
  }
  </code></pre>
  <p>Try to input one character and the result is pretty surprising. For 'a', I get <em>Community\VC\Tools\MSVC\14.28.29910\include\vector</em>, and for 'Z' I get <em>o\2019\Community\VC\Tools\MSVC\14.28.29910\include\vector</em>. This applies to other characters I try to input as well. I really can't find any pattern in this. What does the vector directory have to do with the inputed character?</p>
  <p>I know that such adding string with character is forbidden (adding different entities) and there are many alternatives I used afterwards, but I am interested: Why does this actually happen? Where does the Visual Studio get some <em>random</em> directory, slice it, and serve it in the console?</p>
  <hr />
  <p>As of comments, I now know that I actually added together the address of the string literal and the numerical value of the character. But now I am interested: why are the addresses of string literals always the same? Consider the following code:</p>
  <pre class="lang-cpp prettyprint-override"><code>int main()
  {
      char c;
      std::cin &gt;&gt; c;
      std::cout &lt;&lt; &quot;&quot; + c &lt;&lt; std::endl &lt;&lt; &amp;&quot;&quot; &lt;&lt; std::endl &lt;&lt; &amp;&quot;Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.28.29910/include/vector&quot;;
  }
  </code></pre>
  <p>The addresses of the string literals &quot;&quot; and &quot;Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.28.29910/include/vector&quot; (the longest string I got) are always the same. Why? Isn't the memory address given randomly?</p>