title: Where in memory are my variables stored in C?
body: <p>By considering that the memory is divided into four segments: data, heap, stack, and code, where do global variables, static variables, constant data types, local variables (defined and declared in functions), variables (in main function), pointers, and dynamically allocated space (using malloc and calloc) get stored in memory?</p>
  
  <p>I think they would be allocated as follows:</p>
  
  <ul>
  <li>Global variables  ------->  data</li>
  <li>Static variables  ------->  data</li>
  <li>Constant data types ----->  code</li>
  <li>Local variables (declared and defined in functions)  -------->  stack</li>
  <li>Variables declared and defined in main function  ----->  heap</li>
  <li>Pointers (for example, <code>char *arr</code>, <code>int *arr</code>) ------->  heap</li>
  <li>Dynamically allocated space (using malloc and calloc) --------> stack</li>
  </ul>
  
  <p>I am referring to these variables only from the C perspective.</p>
  
  <p>Please correct me if I am wrong as I am new to C.</p>