title: How does web-assembly allocate memory addresses
body: <p>When running the following C code, I get different values for the address of var each time, which is what one would expect.</p>
  <pre><code>int main()
  {
    int var = 5;
    printf(&quot;var: %d\n&quot;, var);
  
    printf(&quot;address of var: %p\n&quot;, &amp;var);  
    printf(&quot;address of var: %d\n&quot;, &amp;var);  
    return 0;
  }
  </code></pre>
  <p>However if I convert the C to wasm using emsciption and run it, the value for the memory address is the same each time. Does web-assembly hard code memory address?</p>
  <p>I've tried reading up on it but have not found a straight forward answer, <a href="https://www.cs.uaf.edu/courses/cs301/2014-fall/notes/memory/" rel="nofollow noreferrer">https://www.cs.uaf.edu/courses/cs301/2014-fall/notes/memory/</a>, <a href="https://ariya.io/2019/05/basics-of-memory-access-in-webassembly" rel="nofollow noreferrer">https://ariya.io/2019/05/basics-of-memory-access-in-webassembly</a></p>