<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://coderwiki.org/index.php?action=history&amp;feed=atom&amp;title=Global_variable</id>
	<title>Global variable - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://coderwiki.org/index.php?action=history&amp;feed=atom&amp;title=Global_variable"/>
	<link rel="alternate" type="text/html" href="http://coderwiki.org/index.php?title=Global_variable&amp;action=history"/>
	<updated>2026-05-19T01:38:18Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.44.0</generator>
	<entry>
		<id>http://coderwiki.org/index.php?title=Global_variable&amp;diff=72&amp;oldid=prev</id>
		<title>Dylan: info, C example, comparison to local variables</title>
		<link rel="alternate" type="text/html" href="http://coderwiki.org/index.php?title=Global_variable&amp;diff=72&amp;oldid=prev"/>
		<updated>2025-08-12T10:36:24Z</updated>

		<summary type="html">&lt;p&gt;info, C example, comparison to local variables&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;A &amp;#039;&amp;#039;&amp;#039;global variable&amp;#039;&amp;#039;&amp;#039; is a [[variable]] which is valid throughout the [[lifetime]] of the [[program]]&amp;#039;s execution.&lt;br /&gt;
&lt;br /&gt;
By definition, it does &amp;#039;&amp;#039;&amp;#039;not&amp;#039;&amp;#039;&amp;#039; have a [[scope]].&lt;br /&gt;
&lt;br /&gt;
== Example of a global variable in [[C]] ==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot; line=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
int number = 6;&lt;br /&gt;
&lt;br /&gt;
void printNumber() { // no parameters...&lt;br /&gt;
    printf(&amp;quot;%d&amp;quot;, number); // ... but we can still access &amp;#039;number&amp;#039;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
int main() {&lt;br /&gt;
    number = 12; // assign a new value to global variable &amp;#039;number&amp;#039;&lt;br /&gt;
    printNumber(); // prints &amp;#039;12&amp;#039;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Comparison to [[Local variable|local variables]] ==&lt;br /&gt;
[[Local variable|Local variables]] are &amp;#039;&amp;#039;&amp;#039;only valid inside a specific [[scope]]&amp;#039;&amp;#039;&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
Usually, this [[scope]] is a [[code block]], such as an [[if statement]] or [[subroutine]] ([[function]] or [[procedure]]).&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Global&amp;#039;&amp;#039;&amp;#039; [[Variable|variables]] on the other hand are not bound to a specific [[scope]] or [[code block]], but can instead be accessed anywhere in the [[program]].&lt;/div&gt;</summary>
		<author><name>Dylan</name></author>
	</entry>
</feed>