<?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>arrays and pointers | Student Projects</title>
	<atom:link href="https://studentprojects.in/tag/arrays-and-pointers/feed/" rel="self" type="application/rss+xml" />
	<link>https://studentprojects.in</link>
	<description>Microcontroller projects, Circuit Diagrams, Project Ideas</description>
	<lastBuildDate>Thu, 29 Dec 2022 14:03:50 +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>Operations on Pointers-Part II</title>
		<link>https://studentprojects.in/software-development/cpp/operations-on-pointers-part-ii/</link>
					<comments>https://studentprojects.in/software-development/cpp/operations-on-pointers-part-ii/#respond</comments>
		
		<dc:creator><![CDATA[Shubhajna Rai]]></dc:creator>
		<pubDate>Sun, 01 Jan 2023 02:10:00 +0000</pubDate>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[operations on pointers]]></category>
		<category><![CDATA[pointer to pointer]]></category>
		<category><![CDATA[arrays and pointers]]></category>
		<guid isPermaLink="false">https://studentprojects.in/?p=10059</guid>

					<description><![CDATA[<p>Pointer to Pointer Pointer to Pointer is a straightforward idea in which we store the address of one pointer to another. Because of the operator&#8217;s name, this is also known as numerous indirections. The first pointer carries the location of the second pointer, which points to the address where the value of the real variable</p>
<p>The post <a href="https://studentprojects.in/software-development/cpp/operations-on-pointers-part-ii/">Operations on Pointers-Part II</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></description>
										<content:encoded><![CDATA[<h3>Pointer to Pointer</h3>



<p>Pointer to Pointer is a straightforward idea in which we store the address of one pointer to another. Because of the operator&#8217;s name, this is also known as numerous indirections. The first pointer carries the location of the second pointer, which points to the address where the value of the real variable is kept.</p>



<p>An example of how to define a pointer to a pointer.</p>



<pre class="wp-block-code"><code lang="cpp" class="language-cpp">#include &lt;iostream&gt;
using namespace std;
 
int main()
{
    int a = 100;
    int *b = &amp;a;
    int **c = &amp;b;
    cout &lt;&lt; "Value of variable a is " &lt;&lt; a &lt;&lt; endl;
    cout &lt;&lt; "Address of variable a is " &lt;&lt; b &lt;&lt; endl;
    cout &lt;&lt; "Address of pointer b is " &lt;&lt; c &lt;&lt; endl;
    return 0;
}
</code></pre>



<p>Output:</p>



<p>Value of variable a is 100</p>



<p>Address of variable a is 0x61feb8</p>



<p>Address of pointer b is 0x61feb4</p>



<h3>Arrays and Pointers</h3>



<p>Storing an array&#8217;s address into a pointer differs from storing a variable&#8217;s address into a pointer. The name of an array is the address of the array&#8217;s first index. As a result, using the (ampersand)&amp; operator with the array name to assign an address to a pointer is incorrect. Instead, we used the array&#8217;s name.An example programme for saving the array&#8217;s initial address in the pointer,</p>



<pre class="wp-block-code"><code lang="cpp" class="language-cpp">#include &lt;iostream&gt;
using namespace std;
 
int main()
{
    int a = 10;
    cout &lt;&lt; "Address of variable a is " &lt;&lt; &amp;a &lt;&lt; endl;
    return 0;
}
</code></pre>



<p>Output:</p>



<p>The value of marks[0] is 99</p>



<p>We can utilise pointer arithmetic, such as addition and subtraction of pointers, to access other items of the same array that pointer p points to.</p>



<p>*(p+1) returns the value in the array&#8217;s second position. This is how it works:</p>



<pre class="wp-block-code"><code lang="cpp" class="language-cpp">int marks[] = {99, 100, 38};
int *p = marks;
cout &lt;&lt; "The value of marks[0] is " &lt;&lt; *p &lt;&lt; endl;
cout &lt;&lt; "The value of marks[1] is " &lt;&lt; *(p + 1) &lt;&lt; endl;
cout &lt;&lt; "The value of marks[2] is " &lt;&lt; *(p + 2) &lt;&lt; endl;</code></pre>



<p>output:</p>



<pre class="wp-block-code"><code lang="cpp" class="language-cpp">The value of marks[0] is 99
The value of marks[1] is 100
The value of marks[2] is 38
</code></pre><p>The post <a href="https://studentprojects.in/software-development/cpp/operations-on-pointers-part-ii/">Operations on Pointers-Part II</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://studentprojects.in/software-development/cpp/operations-on-pointers-part-ii/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
