<?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>Dereferencing | Student Projects</title>
	<atom:link href="https://studentprojects.in/tag/dereferencing/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:22:08 +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>Wild pointers</title>
		<link>https://studentprojects.in/software-development/c-tutorials/c-tutorials-c-tutorials/wild-pointers/</link>
					<comments>https://studentprojects.in/software-development/c-tutorials/c-tutorials-c-tutorials/wild-pointers/#respond</comments>
		
		<dc:creator><![CDATA[Shubhajna Rai]]></dc:creator>
		<pubDate>Sun, 27 Nov 2022 10:35:00 +0000</pubDate>
				<category><![CDATA[C Tutorials]]></category>
		<category><![CDATA[Dereferencing]]></category>
		<category><![CDATA[Wlid pointers]]></category>
		<guid isPermaLink="false">https://studentprojects.in/?p=9779</guid>

					<description><![CDATA[<p>Even though a wild pointer is a straightforward idea, you still needed a separate tutorial to understand it. Let&#8217;s begin with the definition, then. &#8220;Void pointers are uninitialized pointers.&#8221; Example: In the example above, a pointer was generated but left empty, turning it into a wild pointer. Its drawback is that it will hold any</p>
<p>The post <a href="https://studentprojects.in/software-development/c-tutorials/c-tutorials-c-tutorials/wild-pointers/">Wild pointers</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>Even though a wild pointer is a straightforward idea, you still needed a separate tutorial to understand it. Let&#8217;s begin with the definition, then.</p>



<p>&#8220;Void pointers are uninitialized pointers.&#8221;</p>



<p>Example:</p>



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



<p>In the example above, a pointer was generated but left empty, turning it into a wild pointer.</p>



<p>Its drawback is that it will hold any garbage value, which means it will hold any random portion of memory. Numerous faults in the software may result from the storage of data in an arbitrary location, and occasionally the programmer will not even be able to determine the source.</p>



<p>Solution: We would rather convert a void pointer to a NULL pointer in order to prevent the flaws and errors it may introduce into a programme. As a result, our pointer will always point to 0 or NULL instead of any memory location. Simply setting a wild pointer equal to NULL will make it a NULL pointer. Let&#8217;s look at it using C syntax.</p>



<p>Syntax:</p>



<pre class="wp-block-code"><code lang="c" class="language-c">int *ptr = NULL;</code></pre>



<p>Therefore, if we are not utilising our pointer to point at a specific memory region, we will use this way.The pointer can now be initialised as a second option for preventing similar issues.</p>



<p>Example:</p>



<pre class="wp-block-code"><code lang="c" class="language-c">int x = 3;
int *ptr;
ptr = &amp;3;
</code></pre>



<p>It will be a wild pointer if we simply run the first two lines of the aforementioned section of code because no value has been initialised to it. However, if we run the third line as well, it will point to a specific address and become a normal pointer.</p>



<p>Dereferencing:</p>



<p>We are unable to dereference a wild pointer because we are unsure of the data that it is pointing to in memory. Dereferencing a wild pointer can result in several problems as well as programme failure.</p>



<pre class="wp-block-code"><code lang="c" class="language-c">#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;
int main()
{
    int a =4354;
    int *ptr; // This is a wild pointer
    // *ptr = 34; // This is not a good thing to do
    ptr = &amp;a; // ptr is no longer a wild pointer
    printf("The value of a is %d\n", *ptr);
    return 0;
}
</code></pre><p>The post <a href="https://studentprojects.in/software-development/c-tutorials/c-tutorials-c-tutorials/wild-pointers/">Wild pointers</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/wild-pointers/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Wild Pointer</title>
		<link>https://studentprojects.in/software-development/c-tutorials/c-tutorials-c-tutorials/wild-pointer/</link>
					<comments>https://studentprojects.in/software-development/c-tutorials/c-tutorials-c-tutorials/wild-pointer/#respond</comments>
		
		<dc:creator><![CDATA[Shubhajna Rai]]></dc:creator>
		<pubDate>Tue, 25 Oct 2022 09:03:44 +0000</pubDate>
				<category><![CDATA[C Tutorials]]></category>
		<category><![CDATA[Wild pointers]]></category>
		<category><![CDATA[Avoiding problems due to WILD pointers]]></category>
		<category><![CDATA[Dereferencing]]></category>
		<guid isPermaLink="false">https://studentprojects.in/?p=9708</guid>

					<description><![CDATA[<p>Wild pointers are uninitialized pointers that point to any random position in memory while being unassigned from any other memory location. This could occasionally result in a programme crashing or acting erratically. For instance: A pointer called ptr is generated in this example, but it is empty. The pointer ptr is now a wild pointer</p>
<p>The post <a href="https://studentprojects.in/software-development/c-tutorials/c-tutorials-c-tutorials/wild-pointer/">Wild Pointer</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>Wild pointers are uninitialized pointers that point to any random position in memory while being unassigned from any other memory location. This could occasionally result in a programme crashing or acting erratically.</p>



<p><strong>For instance:</strong></p>



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



<p>A pointer called ptr is generated in this example, but it is empty. The pointer ptr is now a wild pointer as a result. Declaring a pointer without initialising it has drawbacks of its own. One such drawback is that it will save any worthless information in it. It will hold in it arbitrarily a position in memory. This random allocation frequently becomes difficult for a programmer to debug, leading to several issues with the program&#8217;s operation.</p>



<p><strong>A. Avoiding problems due to WILD pointers</strong></p>



<p>In order to avoid problems that can arise while dereferencing a wild reference, we frequently opt to change a void pointer to a NULL pointer. By doing this, our pointer will instead point to a NULL position rather than any trash memory location. Simply setting a wild pointer equal to NULL will make it a NULL pointer.</p>



<p><strong>B. Dereferencing</strong></p>



<p>A wild pointer cannot be dereferenced since we are unsure of the data it is pointing at in memory. Dereferencing a wild pointer can result in numerous problems as well as a software crash.</p>



<p><strong>Example</strong>:</p>



<pre class="wp-block-code"><code lang="c" class="language-c">#include &lt;bits/stdc++.h&gt;
using namespace std;

int main() {
   int *arr;
   for(int i=0; i&lt;5 ; i++)
   cout &lt;&lt; arr[i] &lt;&lt; ” “;
   return 0;
}</code></pre>



<p><strong>Output</strong>:1 0 -426634956 32764 0</p><p>The post <a href="https://studentprojects.in/software-development/c-tutorials/c-tutorials-c-tutorials/wild-pointer/">Wild Pointer</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/wild-pointer/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
