<?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>automatic variables | Student Projects</title>
	<atom:link href="https://studentprojects.in/tag/automatic-variables/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:09:52 +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>What is a local variable?</title>
		<link>https://studentprojects.in/software-development/c-tutorials/c-faq/local-variable/</link>
					<comments>https://studentprojects.in/software-development/c-tutorials/c-faq/local-variable/#respond</comments>
		
		<dc:creator><![CDATA[Chitra]]></dc:creator>
		<pubDate>Tue, 14 Feb 2012 09:47:40 +0000</pubDate>
				<category><![CDATA[C Questions & Answers]]></category>
		<category><![CDATA[automatic]]></category>
		<category><![CDATA[variables]]></category>
		<category><![CDATA[variable types]]></category>
		<category><![CDATA[local and global]]></category>
		<category><![CDATA[auto]]></category>
		<category><![CDATA[automatic variables]]></category>
		<guid isPermaLink="false">http://studentprojects.in/?p=2661</guid>

					<description><![CDATA[<p>Variables that are declared inside a function are called local variables. Local variables can be used only by statements that are inside the block in which the variables are declared. In other words, local variables are not known outside their own code block. A block of code begins with an opening curly brace and terminates</p>
<p>The post <a href="https://studentprojects.in/software-development/c-tutorials/c-faq/local-variable/">What is a local variable?</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>Variables that are declared inside a function are called local variables. Local variables can be used only by statements that are inside the block in which the variables are declared. In other words, local variables are not known outside their own code block. A block of code begins with an opening curly brace and terminates with a closing curly brace.</p>
<p>Local variables exist only while the block of code in which they are declared is executing. That is, a local variable is created upon entry into its block and destroyed upon exit. Furthermore, a variable declared within one code block has no bearing on or relationship to another variable with the same name declared within a different code block.</p>
<p>Example:</p>
<pre lang="c" escaped="true">
void func1(void) 
{ 
  int y; 
  y = 10;
}
void func2(void)
{ 
  int y;
  y = -199;
}
</pre>
<p>The integer variable y is declared twice, once in func1( ) and once in func2( ). The y in func1( ) has no relationship to the y in func2( ). This is because each y is known only to the code within the block in which it is declared.</p>
<p>The C language contains the keyword auto, which can be used to declare local variables. However, since all variables are, by default, assumed to be auto, this keyword is virtually never used. </p><p>The post <a href="https://studentprojects.in/software-development/c-tutorials/c-faq/local-variable/">What is a local variable?</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-faq/local-variable/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
