{"id":4015,"date":"2014-03-30T07:12:52","date_gmt":"2014-03-30T07:12:52","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/in-c-where-are-static-dynamic-and-local-variables-stored-how-about-in-c-and-java-collection-of-common-programming-errors\/"},"modified":"2014-03-30T07:12:52","modified_gmt":"2014-03-30T07:12:52","slug":"in-c-where-are-static-dynamic-and-local-variables-stored-how-about-in-c-and-java-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/in-c-where-are-static-dynamic-and-local-variables-stored-how-about-in-c-and-java-collection-of-common-programming-errors\/","title":{"rendered":"In C++, where are static, dynamic and local variables stored? How about in C and Java?-Collection of common programming errors"},"content":{"rendered":"<p>If you&#8217;re compiling C\/C++ to create a windows executable (or maybe for any x86 system) then static and global variables are usually stored in a segment of the memory called a data segment. This memory is usually also divided to variables which are initialized and those that are not initialized by the program in their definition.<\/p>\n<p>Local variables which are defined inside a functions are allocated on the running stack of the program, alongside the return value of the function.<\/p>\n<p>By &#8220;dynamic&#8221; I&#8217;m assuming you mean things allocated using <code>new<\/code> or <code>malloc<\/code>. These are usually stored in yet another area of memory called &#8220;the heap&#8221; (which has nothing to do with the &#8220;heap&#8221; data structure)<\/p>\n<p>All these details are highly platform dependent and usually, as a programmer you would not need to even be aware of them.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you&#8217;re compiling C\/C++ to create a windows executable (or maybe for any x86 system) then static and global variables are usually stored in a segment of the memory called a data segment. This memory is usually also divided to variables which are initialized and those that are not initialized by the program in their [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-4015","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4015","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=4015"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4015\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=4015"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=4015"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=4015"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}