title: When/where are local arrays allocated?
body: <p><a href="https://www.gnu.org/software/libc/manual/html_node/Memory-Allocation-and-C.html" rel="nofollow noreferrer">https://www.gnu.org/software/libc/manual/html_node/Memory-Allocation-and-C.html</a> describes <em>automatic allocation</em> of local variables. I understand that local variables are commonly allocated on the stack. I can imagine how an <code>int</code> might be allocated on the stack; just push its value. But how might an array be allocated?</p>
  
  <p>For example, if you declare an array <code>char str[10];</code>, does that 10 bytes of space go on the stack, or is it allocated somewhere else, and only the <code>str</code> pointer is pushed to the stack? If the latter, where is the 10 bytes of space allocated?</p>
  
  <p>Furthermore, when exactly are local variables, including arrays, allocated? I commonly see heap allocation referred to as "dynamic allocation", implying that automatic variables are <em>not</em> dynamically allocated. But automatic variables may be declared within flow-of-control constructs and function bodies, so the compiler can't possibly know before runtime exactly how much space will be occupied by automatic variables. So automatic variables must also be dynamically allocated, right?</p>
  
  <p><strong>Edit:</strong> I would like to emphasize the first half of this question. I am most interested in understanding when and where the space for local arrays is allocated. On the stack? Somewhere else?</p>
  
  <p><strong>Edit 2:</strong> I made a mistake when I originally included the C++ tag for this question. I meant to ask only about the <strong>C</strong> language and its implementations. I apologize for any confusion.</p>