<?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>pointers in c | Student Projects</title>
	<atom:link href="https://studentprojects.in/tag/pointers-in-c/feed/" rel="self" type="application/rss+xml" />
	<link>https://studentprojects.in</link>
	<description>Microcontroller projects, Circuit Diagrams, Project Ideas</description>
	<lastBuildDate>Thu, 19 Jan 2012 07:22:36 +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>what is Void Pointer?</title>
		<link>https://studentprojects.in/software-development/c-tutorials/c-faq/void-pointer/</link>
					<comments>https://studentprojects.in/software-development/c-tutorials/c-faq/void-pointer/#comments</comments>
		
		<dc:creator><![CDATA[Chitra]]></dc:creator>
		<pubDate>Thu, 19 Jan 2012 07:18:21 +0000</pubDate>
				<category><![CDATA[C Questions & Answers]]></category>
		<category><![CDATA[pointer concept]]></category>
		<category><![CDATA[pointers in c]]></category>
		<category><![CDATA[void pointer]]></category>
		<category><![CDATA[void pointers]]></category>
		<guid isPermaLink="false">http://studentprojects.in/?p=2609</guid>

					<description><![CDATA[<p>Void pointer or generic pointer is a special type of pointer that can be pointed at objects of any data type. A void pointer is declared like a normal pointer, using the void keyword as the pointer’s type. Pointers defined using specific data type cannot hold the address of the some other type of variable</p>
<p>The post <a href="https://studentprojects.in/software-development/c-tutorials/c-faq/void-pointer/">what is Void Pointer?</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>Void pointer or generic pointer is a special type of pointer that can be pointed at objects of any data type. A void pointer is declared like a normal pointer, using the void keyword as the pointer’s type.</p>
<p>Pointers defined using specific data type cannot hold the address of the some other type of variable i.e., it is incorrect in C++ to assign the address of an integer variable to a pointer of type float.</p>
<p>Example: </p>
<pre lang="c" escaped="true">
float *f; //pointer of type float
int i;  //integer variable
f = &amp;i; //compilation error
</pre>
<p>The above problem can be solved by general purpose pointer called void pointer.</p>
<p>Void pointer can be declared as follows:</p>
<pre lang="c" escaped="true"> 
void *v // defines a pointer of type void
</pre>
<p>The pointer defined in this manner do not have any type associated with them and can hold the address of any type of variable.</p>
<p>Example:</p>
<pre lang="c" escaped="true">
void *v; 
int *i;
int ivar;
char chvar;
float fvar;
v = &amp;ivar; // valid
v = &amp;chvar; //valid
v = &amp;fvar; // valid
i = &amp;ivar; //valid
i = &amp;chvar; //invalid
i = &amp;fvar; //invalid
</pre><p>The post <a href="https://studentprojects.in/software-development/c-tutorials/c-faq/void-pointer/">what is Void 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-faq/void-pointer/feed/</wfw:commentRss>
			<slash:comments>9</slash:comments>
		
		
			</item>
		<item>
		<title>What is dangling pointer?</title>
		<link>https://studentprojects.in/software-development/c-tutorials/c-faq/dangling-pointer/</link>
					<comments>https://studentprojects.in/software-development/c-tutorials/c-faq/dangling-pointer/#respond</comments>
		
		<dc:creator><![CDATA[Chitra]]></dc:creator>
		<pubDate>Tue, 17 Jan 2012 10:43:23 +0000</pubDate>
				<category><![CDATA[C Questions & Answers]]></category>
		<category><![CDATA[dangling pointer]]></category>
		<category><![CDATA[dangling]]></category>
		<category><![CDATA[pointer]]></category>
		<category><![CDATA[pointers]]></category>
		<category><![CDATA[dangling pointers]]></category>
		<category><![CDATA[pointers dangling]]></category>
		<category><![CDATA[pointer concept]]></category>
		<category><![CDATA[pointers in c]]></category>
		<guid isPermaLink="false">http://studentprojects.in/?p=2601</guid>

					<description><![CDATA[<p>Dangling pointers and wild pointers in computer programming are pointers that do not point to a valid object of the appropriate type. In many applications memory is allocated for holding data objects. After using these objects, tha aplication will de-allocate this memory so that the memory can be re-used. In some cases the alications may</p>
<p>The post <a href="https://studentprojects.in/software-development/c-tutorials/c-faq/dangling-pointer/">What is dangling pointer?</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>Dangling pointers and wild pointers in computer programming are pointers that do not point to a valid object of the appropriate type.</p>
<p>In many applications memory is allocated for holding data objects. After using these objects, tha aplication will de-allocate this memory so that the memory can be re-used. In some cases the alications may use a pointer to an object whose memory is already de-allocated. This may lead to application crash or an unpredictable behavior.</p>
<p>scenarios which leads to dangling pointer</p>
<ol>
<li>Application makes use of a object after it has been released, and there by access to an invalid memory location.</li>
<li>A function returns a pointer to one of its local variables, and since this local variable is defined only fro the function, the pointer becomes invalid once the function ends.</li>
</ol>
<p>The most common result of this bug is the crash of the application or its running thread.</p>
<p><strong>Examle 1:</strong></p>
<pre lang="c" escaped="true" line="1">
#include "stdlib.h"
 
void func()
{
    char *dp = malloc(A_CONST);
    /* ... */
    free(dp);         /* dp now becomes a dangling pointer */
    /* ... */
}
</pre>
<p><strong>Example 2:</strong></p>
<pre lang="c" escaped="true" line="1">
{
   char *dp = NULL;
   /* ... */
   {
       char c;
       dp = &amp;c;
   } /* c falls out of scope */
     /* dp is now a dangling pointer */
} 
</pre>
<p><strong>Example 3:</strong></p>
<pre lang="c" escaped="true" line="1">
#include "stdio.h"

int *call();
void main(){

int *ptr;
ptr=call();

fflush(stdin);
printf("%d",*ptr);
}

int * call(){

int x=25;
++x;

return &amp;x;
}
</pre><p>The post <a href="https://studentprojects.in/software-development/c-tutorials/c-faq/dangling-pointer/">What is dangling 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-faq/dangling-pointer/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
