<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>static variable | Student Projects</title>
	<atom:link href="https://studentprojects.in/tag/static-variable/feed/" rel="self" type="application/rss+xml" />
	<link>https://studentprojects.in</link>
	<description>Microcontroller projects, Circuit Diagrams, Project Ideas</description>
	<lastBuildDate>Sat, 10 Dec 2022 04:21:58 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.1.7</generator>
	<item>
		<title>Storage classes</title>
		<link>https://studentprojects.in/software-development/c-tutorials/c-tutorials-c-tutorials/storage-classes/</link>
					<comments>https://studentprojects.in/software-development/c-tutorials/c-tutorials-c-tutorials/storage-classes/#respond</comments>
		
		<dc:creator><![CDATA[Shubhajna Rai]]></dc:creator>
		<pubDate>Mon, 28 Nov 2022 08:31:00 +0000</pubDate>
				<category><![CDATA[C Tutorials]]></category>
		<category><![CDATA[automatic variables]]></category>
		<category><![CDATA[static variable]]></category>
		<category><![CDATA[Storage class]]></category>
		<category><![CDATA[external variables]]></category>
		<category><![CDATA[resgister variables]]></category>
		<guid isPermaLink="false">https://studentprojects.in/?p=9777</guid>

					<description><![CDATA[<p>&#8220;A storage class defines a variable&#8217;s lifetime, default initial value, and scope.&#8221; The variable&#8217;s accessibility in these contexts is referred to as scope. Both the initial default value and the lifetime of a variable relate to the value that was there by default before the variable was initialised. Let&#8217;s move on to its types now</p>
<p>The post <a href="https://studentprojects.in/software-development/c-tutorials/c-tutorials-c-tutorials/storage-classes/">Storage classes</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>&#8220;A storage class defines a variable&#8217;s lifetime, default initial value, and scope.&#8221;</p>



<p>The variable&#8217;s accessibility in these contexts is referred to as scope. Both the initial default value and the lifetime of a variable relate to the value that was there by default before the variable was initialised.</p>



<p>Let&#8217;s move on to its types now that we are familiar with the fundamental idea of storage classes. Depending on the kind of variables they hold, there are four different sorts of storage classes. The various storage classes are as follows. Their names give away the stored variables:</p>



<ul><li>Automatic Variables</li><li>External Variables</li><li>Static Variables</li><li>Register Variables</li></ul>



<p><strong>Auto Storage Class:</strong></p>



<p>This category applies automatically to variables that are created as part of a function but whose storage class has not yet been defined. As it can only be accessed within the function it is initialised in, its scope is minimal. Nothing else can access it. The variable initially holds a trash value until a value is assigned to it. Their lifespan is the amount of time till the function block ends, hence it depends on the duration of the function block.</p>



<div class="is-layout-flow wp-block-group"><div class="wp-block-group__inner-container">
<pre class="wp-block-code"><code lang="c" class="language-c">int a;
auto int a;
//Both are the same.
</code></pre>
</div></div>



<p><strong>External Storage Class:</strong></p>



<p>Because these variables are defined externally to the function, they can be used anywhere inside the function, making them universally applicable. Their starting value is zero. Their lifetime is equivalent to the duration of the programme because they can be used at any moment. It&#8217;s not usually a good idea to have too many global variables in a programme because they can compromise security.</p>



<p><strong>Extern Keyword:</strong></p>



<p>Use of the extern keyword tells the compiler that the variable has previously been defined somewhere else. By doing this, we may access the same variable in another file without allocating new memory and use it with the same space. Since we must use the extern keyword and it will automatically access it from the other file, its syntax is straightforward.</p>



<p>Syntax:</p>



<pre class="wp-block-code"><code lang="c" class="language-c">extern int a;</code></pre>



<p><strong>Static Storage Class:</strong></p>



<p>Static variables are a little more technical because they are only valid for the function they are initialised in throughout the entire programme. It is useful when we modify the program&#8217;s value since the new value will be stored and overwritten by the old one. Their syntax is relatively simple because we just need to apply the Static keyword during initialization, and their initial default value is 0.</p>



<p>Syntax:</p>



<pre class="wp-block-code"><code class="">static int a;</code></pre>



<p><strong>Register Storage Class:</strong></p>



<p>As its scope is restricted to the function it is defined in, its initial default value is 0, and its lifetime is limited to the end of the function block, the Register Storage Class is very similar to the Auto Storage Class. Now, the main distinction between it and the others is that it seeks rapid access to the CPU&#8217;s register memory rather than the local memory. It is typically used for programmes that must be accessed more quickly than others or that are frequently used.</p>



<p>Syntax:</p>



<pre class="wp-block-code"><code lang="c" class="language-c">register int a;</code></pre><p>The post <a href="https://studentprojects.in/software-development/c-tutorials/c-tutorials-c-tutorials/storage-classes/">Storage classes</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://studentprojects.in/software-development/c-tutorials/c-tutorials-c-tutorials/storage-classes/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>C Static Variables</title>
		<link>https://studentprojects.in/software-development/c-tutorials/c-tutorials-c-tutorials/c-static-variables/</link>
					<comments>https://studentprojects.in/software-development/c-tutorials/c-tutorials-c-tutorials/c-static-variables/#respond</comments>
		
		<dc:creator><![CDATA[Shubhajna Rai]]></dc:creator>
		<pubDate>Tue, 25 Oct 2022 09:04:59 +0000</pubDate>
				<category><![CDATA[C Tutorials]]></category>
		<category><![CDATA[local variable]]></category>
		<category><![CDATA[c static variable]]></category>
		<category><![CDATA[worldwide variable]]></category>
		<category><![CDATA[static variable]]></category>
		<guid isPermaLink="false">https://studentprojects.in/?p=9711</guid>

					<description><![CDATA[<p>A.Local Variables Variables declared within a function or a block of code are referred to as local variables. These variables are only accessible within the function in which they were declared. Local variables have a function-specific scope since they can only be accessed by statements that are included within that function or code block. B.</p>
<p>The post <a href="https://studentprojects.in/software-development/c-tutorials/c-tutorials-c-tutorials/c-static-variables/">C Static Variables</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></description>
										<content:encoded><![CDATA[<p><strong>A.Local Variables</strong></p>



<ul><li>Variables declared within a function or a block of code are referred to as local variables. These variables are only accessible within the function in which they were declared. Local variables have a function-specific scope since they can only be accessed by statements that are included within that function or code block.</li></ul>



<p><strong>B. Worldwide Variables</strong></p>



<ul><li>Global variables are those that have definitions separate from any and all functions. We can access global variables within any of the program&#8217;s declared functions to retrieve their values. The system initialises global variables when they are defined. When a name is defined for both local and global variables, the local variable is given preference.</li></ul>



<p><strong>C. Static Variables</strong></p>



<ul><li>One definition of a static variable is one that keeps its value even after the programme leaves the scope in which it was declared. Static variables don&#8217;t need to be initialised afresh in the new scope; they keep their value. Static variables retain their memory until the program&#8217;s end, but regular variables are deleted when the function they were declared in is exited. Both inside and outside of the function they can be declared. The block is the local area for static variables. A static variable&#8217;s default value is zero. A static variable is declared with the word static.</li></ul>



<p><strong>Output:</strong></p>



<p>static datatype variable_name = variable_value;</p>



<p>Static global variables differ from static local variables.</p>



<p><strong>Static global variable</strong></p>



<ul><li>Static global variables are any variables with the static keyword specified outside of a function. Any method in the application will allow access to this variable.</li></ul>



<p><strong>Static local variable</strong></p>



<ul><li>Static local variables are any variables that are declared with the static keyword inside of a function. A static local variable has the same scope as a local variable, but its memory is accessible for the duration of the program&#8217;s execution.</li></ul>



<p><strong>The characteristics of static variables</strong></p>



<ul><li>A static variable&#8217;s value will remain after the programme leaves the scope in which it was declared.</li><li>A static variable&#8217;s allotted memory is accessible for the duration of the program&#8217;s execution.</li><li>A static variable&#8217;s default value is 0 if we don&#8217;t initialise it.</li></ul><p>The post <a href="https://studentprojects.in/software-development/c-tutorials/c-tutorials-c-tutorials/c-static-variables/">C Static Variables</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://studentprojects.in/software-development/c-tutorials/c-tutorials-c-tutorials/c-static-variables/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
