{"id":11175,"date":"2024-12-07T14:06:55","date_gmt":"2024-12-07T14:06:55","guid":{"rendered":"https:\/\/cstaleem.com\/?p=11175"},"modified":"2024-11-07T14:13:34","modified_gmt":"2024-11-07T14:13:34","slug":"pointer-in-c-programming-examples-double-pointer-use","status":"publish","type":"post","link":"https:\/\/cstaleem.com\/pointer-in-c-programming-examples-double-pointer-use","title":{"rendered":"Pointer In C Programming Examples | Double Pointer &#038; Use"},"content":{"rendered":"<h1><span style=\"font-family: arial, helvetica, sans-serif;\">Pointer In C Programming Examples | Double Pointer &amp; Use<\/span><\/h1>\n<p><span style=\"font-family: arial, helvetica, sans-serif;\">A pointer is also a variable that stores the memory address of another variable. The pointer variable itself also contains the address of memory. Pointers cannot store direct values; they only store memory addresses of where values are located.<\/span><\/p>\n<p><span style=\"font-family: arial, helvetica, sans-serif;\">This is useful for various reasons, such as dynamic memory allocation, arrays, and functions. <\/span><span style=\"font-family: arial, helvetica, sans-serif;\">As we know compiler assigns a unique address to each variable in a program.<\/span><\/p>\n<p><img fetchpriority=\"high\" decoding=\"async\" class=\"aligncenter size-full wp-image-11160\" src=\"https:\/\/cstaleem.com\/wp-content\/uploads\/2024\/11\/How-Memory-address-is-find-Using-Pointers-in-C.png\" alt=\"How Memory address is find Using Pointers in C\" width=\"544\" height=\"243\" srcset=\"https:\/\/cstaleem.com\/wp-content\/uploads\/2024\/11\/How-Memory-address-is-find-Using-Pointers-in-C.png 544w, https:\/\/cstaleem.com\/wp-content\/uploads\/2024\/11\/How-Memory-address-is-find-Using-Pointers-in-C-300x134.png 300w\" sizes=\"(max-width: 544px) 100vw, 544px\" \/><\/p>\n<h2><span style=\"font-family: arial, helvetica, sans-serif;\"><strong>\u00a0<span style=\"font-size: 18pt;\">Pointer Declaration and Initialization: Code Example\u00a0<\/span><\/strong><\/span><\/h2>\n<p><span style=\"font-family: arial, helvetica, sans-serif;\">Here\u2019s a very simple example of pointer declaration and initialization in C<\/span><\/p>\n<pre><span style=\"font-family: arial, helvetica, sans-serif;\">#include &lt;stdio.h&gt;<\/span>\r\n<span style=\"font-family: arial, helvetica, sans-serif;\">int main()<\/span>\r\n<span style=\"font-family: arial, helvetica, sans-serif;\">{<\/span>\r\n<span style=\"font-family: arial, helvetica, sans-serif;\"> \u00a0\u00a0 int a = 20;<\/span>\r\n<span style=\"font-family: arial, helvetica, sans-serif;\"> \u00a0\u00a0 int *ptr;\u00a0\u00a0\u00a0\u00a0\u00a0 \/\/ pointer declaration<\/span>\r\n<span style=\"font-family: arial, helvetica, sans-serif;\"> \u00a0\u00a0 ptr = &amp;a;\u00a0\u00a0\u00a0\u00a0\u00a0 \/\/ pointer initialization<\/span>\r\n<span style=\"font-family: arial, helvetica, sans-serif;\"> \u00a0\u00a0 printf(\"Address of a: %p\\n\", &amp;a);\u00a0 \/\/ Output: a's address<\/span>\r\n<span style=\"font-family: arial, helvetica, sans-serif;\"> \u00a0\u00a0 printf(\"Address of *ptr: %p\\n\", &amp;(*ptr));\u00a0 \/\/ Output: a's address<\/span>\r\n<span style=\"font-family: arial, helvetica, sans-serif;\"> \u00a0\u00a0 printf(\"Value of ptr: %p\\n\", ptr);\u00a0 \/\/ Output: a's address<\/span>\r\n<span style=\"font-family: arial, helvetica, sans-serif;\"> \u00a0\u00a0 printf(\"Value of a: %d\\n\", a);\u00a0 \/\/ Output: 20 (value of a)<\/span>\r\n<span style=\"font-family: arial, helvetica, sans-serif;\"> \u00a0\u00a0 printf(\"Value of *ptr: %d\\n\", *ptr);\u00a0 \/\/ Output: 20 (value at a's address)<\/span>\r\n<span style=\"font-family: arial, helvetica, sans-serif;\"> \u00a0\u00a0 printf(\"Value of *&amp;a: %d\\n\", *(&amp;a));\u00a0 \/\/ Output: 20 (same as above)<\/span>\r\n<span style=\"font-family: arial, helvetica, sans-serif;\"> \u00a0\u00a0 printf(\"Address of ptr: %p\\n\", &amp;ptr);\u00a0 \/\/ Output: ptr's address<\/span>\r\n<span style=\"font-family: arial, helvetica, sans-serif;\"> \u00a0\u00a0 return 0;<\/span>\r\n<span style=\"font-family: arial, helvetica, sans-serif;\">}<\/span><\/pre>\n<p><span style=\"font-family: arial, helvetica, sans-serif;\"><strong>Output:<\/strong><\/span><\/p>\n<pre><span style=\"font-family: arial, helvetica, sans-serif;\">Address of a: 000000000061FE1C<\/span>\r\n<span style=\"font-family: arial, helvetica, sans-serif;\">Address of *ptr: 000000000061FE1C<\/span>\r\n<span style=\"font-family: arial, helvetica, sans-serif;\">Value of ptr: 000000000061FE1C<\/span>\r\n<span style=\"font-family: arial, helvetica, sans-serif;\">Value of a: 20<\/span>\r\n<span style=\"font-family: arial, helvetica, sans-serif;\">Value of *ptr: 20<\/span>\r\n<span style=\"font-family: arial, helvetica, sans-serif;\">Value of *&amp;a: 20<\/span>\r\n<span style=\"font-family: arial, helvetica, sans-serif;\">Address of ptr: 000000000061FE10<\/span><\/pre>\n<p><span style=\"font-family: arial, helvetica, sans-serif;\"><strong>Explanation: <\/strong><\/span><span style=\"font-family: arial, helvetica, sans-serif;\"><strong>&amp;var<\/strong> gives the address of var. <\/span><span style=\"font-family: arial, helvetica, sans-serif;\"><strong>*ptr<\/strong> giving you the value stored at that address.<\/span><\/p>\n<table style=\"border-collapse: collapse; width: 100%;\">\n<tbody>\n<tr>\n<td style=\"width: 100%;\"><span style=\"font-family: arial, helvetica, sans-serif;\"><strong>Important<\/strong>:<\/span><\/p>\n<p><span style=\"font-family: arial, helvetica, sans-serif;\"> <strong>Dereferencing<\/strong> a pointer means accessing the value stored at the memory address the pointer holds. dereferencing a pointer is done using the * operator.<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2><span style=\"font-family: arial, helvetica, sans-serif;\"><strong>Double Pointer (Pointer to Pointer)<\/strong><\/span><\/h2>\n<p><span style=\"font-family: arial, helvetica, sans-serif;\">In C, a pointer-to-pointer (or &#8220;double pointer&#8221;) allows us to store the address of another pointer. Here\u2019s a simple example diagram<\/span><\/p>\n<p><img decoding=\"async\" class=\"aligncenter size-full wp-image-11159\" src=\"https:\/\/cstaleem.com\/wp-content\/uploads\/2024\/11\/double-pointers-in-programming.png\" alt=\"double pointers in programming\" width=\"570\" height=\"80\" srcset=\"https:\/\/cstaleem.com\/wp-content\/uploads\/2024\/11\/double-pointers-in-programming.png 570w, https:\/\/cstaleem.com\/wp-content\/uploads\/2024\/11\/double-pointers-in-programming-300x42.png 300w\" sizes=\"(max-width: 570px) 100vw, 570px\" \/><\/p>\n<p><span style=\"font-family: arial, helvetica, sans-serif;\"><strong>According to above diagram,\u00a0<\/strong><\/span><span style=\"font-family: arial, helvetica, sans-serif;\"><strong>var<\/strong> is an integer variable set to 20. <\/span><span style=\"font-family: arial, helvetica, sans-serif;\"><strong>ptr1<\/strong> is a pointer variable that holds the address of var. <\/span><span style=\"font-family: arial, helvetica, sans-serif;\"><strong>ptr2<\/strong> is a pointer-to-pointer variable that holds the address of ptr1.<\/span><\/p>\n<h3><span style=\"font-family: arial, helvetica, sans-serif;\"><strong>Double Pointer Code Example<\/strong><\/span><\/h3>\n<pre><span style=\"font-family: arial, helvetica, sans-serif;\">#include &lt;stdio.h&gt;<\/span>\r\n<span style=\"font-family: arial, helvetica, sans-serif;\">int main() {<\/span>\r\n<span style=\"font-family: arial, helvetica, sans-serif;\"> \u00a0\u00a0 int var = 20;<\/span>\r\n<span style=\"font-family: arial, helvetica, sans-serif;\"> \u00a0\u00a0 int *ptr1 = &amp;var;\u00a0\u00a0 \/\/ Pointer to var<\/span>\r\n<span style=\"font-family: arial, helvetica, sans-serif;\"> \u00a0\u00a0 int **ptr2 = &amp;ptr1; \/\/ Pointer to ptr1<\/span>\r\n<span style=\"font-family: arial, helvetica, sans-serif;\"> \u00a0\u00a0 printf(\"Value pointed to by ptr: %d\\n\", *ptr1); \/\/ Prints 20<\/span>\r\n<span style=\"font-family: arial, helvetica, sans-serif;\"> \u00a0\u00a0 printf(\"Value pointed to by pptr: %d\\n\", **ptr2); \/\/ Prints 20<\/span>\r\n<span style=\"font-family: arial, helvetica, sans-serif;\"> \u00a0\u00a0 return 0;\r\n<\/span><span style=\"font-family: arial, helvetica, sans-serif;\">}<\/span><\/pre>\n<p><span style=\"font-family: arial, helvetica, sans-serif;\"><strong>Output:<\/strong><\/span><\/p>\n<pre><span style=\"font-family: arial, helvetica, sans-serif;\">Value pointed to by ptr: 20<\/span>\r\n<span style=\"font-family: arial, helvetica, sans-serif;\">Value pointed to by pptr: 20<\/span><\/pre>\n<h2><span style=\"font-family: arial, helvetica, sans-serif; font-size: 18pt;\">Use of Pointer<\/span><\/h2>\n<p><span style=\"font-family: arial, helvetica, sans-serif;\">Pointers are very powerful and useful in programming, especially in languages like C and C++. Here are some key uses of pointers:<\/span><\/p>\n<h3><span style=\"font-family: arial, helvetica, sans-serif;\">1. <strong>Dynamic Memory Allocation<\/strong><\/span><\/h3>\n<p><span style=\"font-family: arial, helvetica, sans-serif;\">Pointers are essential for managing memory dynamically. Functions like <code>malloc<\/code>, <code>calloc<\/code>, and <code>free<\/code> use pointers to allocate and deallocate memory.<\/span><\/p>\n<p><span style=\"font-family: arial, helvetica, sans-serif;\"><strong>Example:<\/strong><\/span><\/p>\n<div class=\"contain-inline-size rounded-md border-[0.5px] border-token-border-medium relative bg-token-sidebar-surface-primary dark:bg-gray-950\">\n<pre class=\"overflow-y-auto p-4\" dir=\"ltr\"><span style=\"font-family: arial, helvetica, sans-serif;\"><code class=\"!whitespace-pre hljs language-c\"><span class=\"hljs-type\">int<\/span> *ptr = (<span class=\"hljs-type\">int<\/span>*) <span class=\"hljs-built_in\">malloc<\/span>(<span class=\"hljs-keyword\">sizeof<\/span>(<span class=\"hljs-type\">int<\/span>) * <span class=\"hljs-number\">5<\/span>);  <span class=\"hljs-comment\">\/\/ Allocates memory for 5 integers<\/span>\u00a0<\/code><\/span><\/pre>\n<\/div>\n<h3><span style=\"font-family: arial, helvetica, sans-serif;\">2. <strong>Efficient Array and String Handling<\/strong><\/span><\/h3>\n<p><span style=\"font-family: arial, helvetica, sans-serif;\">Pointers provide direct access to array elements and can optimize string manipulation, as arrays are essentially pointers to the first element.<\/span><\/p>\n<p><span style=\"font-family: arial, helvetica, sans-serif;\"><strong>Example:<\/strong><\/span><\/p>\n<div class=\"contain-inline-size rounded-md border-[0.5px] border-token-border-medium relative bg-token-sidebar-surface-primary dark:bg-gray-950\">\n<pre class=\"overflow-y-auto p-4\" dir=\"ltr\"><span style=\"font-family: arial, helvetica, sans-serif;\"><code class=\"!whitespace-pre hljs language-c\"><span class=\"hljs-type\">int<\/span> arr[] = {4<span class=\"hljs-number\">1<\/span>, <span class=\"hljs-number\">25<\/span>, <span class=\"hljs-number\">33<\/span>, <span class=\"hljs-number\">41<\/span>, <span class=\"hljs-number\">50<\/span>};<\/code><\/span>\r\n<span style=\"font-family: arial, helvetica, sans-serif;\"><code class=\"!whitespace-pre hljs language-c\"><span class=\"hljs-type\">int<\/span> *ptr = arr;  <span class=\"hljs-comment\">\/\/ Pointer to the first element of the array\r\n<\/span><\/code><\/span>printf(\"%d \\n\", *(ptr)); \/\/ Dereferencing pointer (output 41)\r\n<code class=\"!whitespace-pre hljs language-c\"><span class=\"hljs-built_in\">printf<\/span>(<span class=\"hljs-string\">\"%d\\n\"<\/span>, *(ptr + <span class=\"hljs-number\">2<\/span>));  <span class=\"hljs-comment\">\/\/ Access the third element: 33\r\n<\/span><\/code>\/\/ Accessing and printing each element using pointer\r\nfor (int i = 0; i &lt; 5; i++) {\r\nprintf(\"%d \", *(ptr + i)); \/\/ Dereferencing pointer to access elements\r\n}\r\nprintf(\"\\n\"); \/\/ Output: <span style=\"font-family: arial, helvetica, sans-serif;\"><code class=\"!whitespace-pre hljs language-c\">4<span class=\"hljs-number\">1<\/span>, <span class=\"hljs-number\">25<\/span>, <span class=\"hljs-number\">33<\/span>, <span class=\"hljs-number\">41<\/span>, <span class=\"hljs-number\">50\r\n<\/span><\/code><\/span>return 0;\r\n}<\/pre>\n<\/div>\n<h3><span style=\"font-family: arial, helvetica, sans-serif;\">3. <strong>Function Arguments (Passing by Reference)<\/strong><\/span><\/h3>\n<p><span style=\"font-family: arial, helvetica, sans-serif;\">Pointers allow passing by reference, enabling functions to modify the original data, which is efficient in terms of memory and performance.<\/span><\/p>\n<p><span style=\"font-family: arial, helvetica, sans-serif;\"><strong>Example:<\/strong><\/span><\/p>\n<pre><span style=\"font-family: arial, helvetica, sans-serif;\">void updateValue(int *ptr) {\r\n<\/span>*ptr = 20; \/\/ Dereference and modify the original value\r\n}\r\nint main() {\r\nint number = 10;\r\nupdateValue(&amp;number); \/\/ Pass the address of 'number'\r\nprintf(\"%d\", number); \/\/ Prints 20\r\nreturn 0;\r\n}<\/pre>\n<div class=\"contain-inline-size rounded-md border-[0.5px] border-token-border-medium relative bg-token-sidebar-surface-primary dark:bg-gray-950\">\n<div class=\"overflow-y-auto p-4\" dir=\"ltr\">\n<h3><span style=\"font-family: arial, helvetica, sans-serif;\">4. <\/span><strong style=\"font-family: arial, helvetica, sans-serif;\">Building Data Structures (Linked Lists, Trees, Graphs)<\/strong><\/h3>\n<\/div>\n<\/div>\n<p><span style=\"font-family: arial, helvetica, sans-serif;\">Pointers are crucial for building complex data structures like linked lists, trees, and graphs, where each element points to others.<\/span><\/p>\n<p><span style=\"font-family: arial, helvetica, sans-serif;\"><strong>Example (Linked List):<\/strong><\/span><\/p>\n<div class=\"contain-inline-size rounded-md border-[0.5px] border-token-border-medium relative bg-token-sidebar-surface-primary dark:bg-gray-950\">\n<pre class=\"overflow-y-auto p-4\" dir=\"ltr\"><span style=\"font-family: arial, helvetica, sans-serif;\"><code class=\"!whitespace-pre hljs language-c\"><span class=\"hljs-class\"><span class=\"hljs-keyword\">struct<\/span> <span class=\"hljs-title\">Node<\/span> {<\/span><\/code><\/span>\r\n<span style=\"font-family: arial, helvetica, sans-serif;\"><code class=\"!whitespace-pre hljs language-c\">    <span class=\"hljs-type\">int<\/span> data;<\/code><\/span>\r\n<span style=\"font-family: arial, helvetica, sans-serif;\"><code class=\"!whitespace-pre hljs language-c\">    <span class=\"hljs-class\"><span class=\"hljs-keyword\">struct<\/span> <span class=\"hljs-title\">Node<\/span> *<span class=\"hljs-title\">next<\/span>;<\/span>  <span class=\"hljs-comment\">\/\/ Pointer to the next node<\/span><\/code><\/span>\r\n<span style=\"font-family: arial, helvetica, sans-serif;\"><code class=\"!whitespace-pre hljs language-c\">};\r\n<\/code><\/span><\/pre>\n<\/div>\n<h3><span style=\"font-family: arial, helvetica, sans-serif;\">5. <strong>Accessing Hardware and Memory Directly<\/strong><\/span><\/h3>\n<p><span style=\"font-family: arial, helvetica, sans-serif;\">In low-level programming (e.g., embedded systems), pointers can access hardware memory directly, useful for controlling hardware registers.<\/span><\/p>\n<p><span style=\"font-family: arial, helvetica, sans-serif;\"><strong>Example:<\/strong><\/span><\/p>\n<div class=\"contain-inline-size rounded-md border-[0.5px] border-token-border-medium relative bg-token-sidebar-surface-primary dark:bg-gray-950\">\n<pre class=\"overflow-y-auto p-4\" dir=\"ltr\"><span style=\"font-family: arial, helvetica, sans-serif;\"><code class=\"!whitespace-pre hljs language-c\"><span class=\"hljs-type\">int<\/span> *port = (<span class=\"hljs-type\">int<\/span> *) <span class=\"hljs-number\">0x4000<\/span>;  <span class=\"hljs-comment\">\/\/ Pointer to a memory-mapped register<\/span><\/code><\/span><span style=\"font-family: arial, helvetica, sans-serif;\"><code class=\"!whitespace-pre hljs language-c\">\r\n*port = <span class=\"hljs-number\">1<\/span>;  <span class=\"hljs-comment\">\/\/ Set the register value to 1<\/span>\r\n<\/code><\/span><\/pre>\n<\/div>\n<h3><span style=\"font-family: arial, helvetica, sans-serif;\">6. <strong>Pointer Arithmetic<\/strong><\/span><\/h3>\n<p><span style=\"font-family: arial, helvetica, sans-serif;\">Pointers allow arithmetic operations (like incrementing or decrementing) to traverse arrays or other memory blocks efficiently.<\/span><\/p>\n<p><span style=\"font-family: arial, helvetica, sans-serif;\"><strong>Example:<\/strong><\/span><\/p>\n<div class=\"contain-inline-size rounded-md border-[0.5px] border-token-border-medium relative bg-token-sidebar-surface-primary dark:bg-gray-950\">\n<pre class=\"overflow-y-auto p-4\" dir=\"ltr\"><span style=\"font-family: arial, helvetica, sans-serif;\"><code class=\"!whitespace-pre hljs language-c\"><span class=\"hljs-type\">int<\/span> arr[] = {<span class=\"hljs-number\">1<\/span>, <span class=\"hljs-number\">2<\/span>, <span class=\"hljs-number\">3<\/span>, <span class=\"hljs-number\">4<\/span>};<\/code><\/span>\r\n<span style=\"font-family: arial, helvetica, sans-serif;\"><code class=\"!whitespace-pre hljs language-c\"><span class=\"hljs-type\">int<\/span> *ptr = arr;\r\n<span class=\"hljs-built_in\">printf<\/span>(<span class=\"hljs-string\">\"%d\\n\"<\/span>, *(ptr + <span class=\"hljs-number\">1<\/span>));<\/code><\/span><span style=\"font-family: arial, helvetica, sans-serif;\"><code class=\"!whitespace-pre hljs language-c\">  <span class=\"hljs-comment\">\/\/ Prints 2, accessing the second element<\/span><\/code><\/span><\/pre>\n<\/div>\n<h3><span style=\"font-family: arial, helvetica, sans-serif;\">7. <strong>Pointers to Functions<\/strong><\/span><\/h3>\n<p><span style=\"font-family: arial, helvetica, sans-serif;\">Function pointers allow you to store addresses of functions, enabling callback mechanisms and flexible programming patterns.<\/span><\/p>\n<p><span style=\"font-family: arial, helvetica, sans-serif;\"><strong>Example:<\/strong><\/span><\/p>\n<div class=\"contain-inline-size rounded-md border-[0.5px] border-token-border-medium relative bg-token-sidebar-surface-primary dark:bg-gray-950\">\n<pre class=\"overflow-y-auto p-4\" dir=\"ltr\"><span style=\"font-family: arial, helvetica, sans-serif;\"><code class=\"!whitespace-pre hljs language-c\"><span class=\"hljs-type\">void<\/span> <span class=\"hljs-title function_\">printMessage<\/span><span class=\"hljs-params\">()<\/span> {<\/code><\/span>\r\n<span style=\"font-family: arial, helvetica, sans-serif;\"><code class=\"!whitespace-pre hljs language-c\">    <span class=\"hljs-built_in\">printf<\/span>(<span class=\"hljs-string\">\"Hello, world!\\n\"<\/span>);<\/code><\/span>\r\n<span style=\"font-family: arial, helvetica, sans-serif;\"><code class=\"!whitespace-pre hljs language-c\">}<\/code><\/span>\r\n<span style=\"font-family: arial, helvetica, sans-serif;\"><code class=\"!whitespace-pre hljs language-c\"><span class=\"hljs-type\">int<\/span> <span class=\"hljs-title function_\">main<\/span><span class=\"hljs-params\">()<\/span> {<\/code><\/span>\r\n<span style=\"font-family: arial, helvetica, sans-serif;\"><code class=\"!whitespace-pre hljs language-c\">    <span class=\"hljs-type\">void<\/span> (*funcPtr)() = printMessage;  <span class=\"hljs-comment\">\/\/ Pointer to 'printMessage'<\/span><\/code><\/span>\r\n<span style=\"font-family: arial, helvetica, sans-serif;\"><code class=\"!whitespace-pre hljs language-c\">    funcPtr();  <span class=\"hljs-comment\">\/\/ Calls 'printMessage' via the pointer<\/span><\/code><\/span><span style=\"font-family: arial, helvetica, sans-serif;\"><code class=\"!whitespace-pre hljs language-c\">\r\n    <span class=\"hljs-keyword\">return<\/span> <span class=\"hljs-number\">0<\/span>;\r\n<\/code><\/span><span style=\"font-family: arial, helvetica, sans-serif;\"><code class=\"!whitespace-pre hljs language-c\">}<\/code><\/span><\/pre>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Pointer In C Programming Examples | Double Pointer &amp; Use A pointer is also a variable that stores the memory address of another variable. The pointer variable itself also contains the address of memory. Pointers cannot store direct values; they only store memory addresses of where values are located. This is useful for various reasons, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1365,1362],"tags":[],"class_list":["post-11175","post","type-post","status-publish","format-standard","hentry","category-c-pointers","category-c-programming"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v22.1 (Yoast SEO v27.9) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Pointer In C Programming Examples | Double Pointer &amp; Use &#187; CS Taleem<\/title>\n<meta name=\"description\" content=\"A pointer is also a variable that stores the memory address of another variable. The pointer variable itself also contains a memory address.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/cstaleem.com\/pointer-in-c-programming-examples-double-pointer-use\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Pointer In C Programming Examples | Double Pointer &amp; Use\" \/>\n<meta property=\"og:description\" content=\"A pointer is also a variable that stores the memory address of another variable. The pointer variable itself also contains a memory address.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/cstaleem.com\/pointer-in-c-programming-examples-double-pointer-use\" \/>\n<meta property=\"og:site_name\" content=\"CS Taleem\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/web.facebook.com\/cstaleem\" \/>\n<meta property=\"article:author\" content=\"https:\/\/web.facebook.com\/CSTaleem\" \/>\n<meta property=\"article:published_time\" content=\"2024-12-07T14:06:55+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/cstaleem.com\/wp-content\/uploads\/2024\/11\/How-Memory-address-is-find-Using-Pointers-in-C.png\" \/>\n<meta name=\"author\" content=\"cst\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@saimaltaf15\" \/>\n<meta name=\"twitter:site\" content=\"@saimaltaf15\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"cst\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/cstaleem.com\\\/pointer-in-c-programming-examples-double-pointer-use#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/cstaleem.com\\\/pointer-in-c-programming-examples-double-pointer-use\"},\"author\":{\"name\":\"cst\",\"@id\":\"https:\\\/\\\/cstaleem.com\\\/#\\\/schema\\\/person\\\/15225ff8956c5ab2b61229458d540915\"},\"headline\":\"Pointer In C Programming Examples | Double Pointer &#038; Use\",\"datePublished\":\"2024-12-07T14:06:55+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/cstaleem.com\\\/pointer-in-c-programming-examples-double-pointer-use\"},\"wordCount\":403,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/cstaleem.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/cstaleem.com\\\/pointer-in-c-programming-examples-double-pointer-use#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/cstaleem.com\\\/wp-content\\\/uploads\\\/2024\\\/11\\\/How-Memory-address-is-find-Using-Pointers-in-C.png\",\"articleSection\":[\"C Pointers\",\"C Programming\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/cstaleem.com\\\/pointer-in-c-programming-examples-double-pointer-use#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/cstaleem.com\\\/pointer-in-c-programming-examples-double-pointer-use\",\"url\":\"https:\\\/\\\/cstaleem.com\\\/pointer-in-c-programming-examples-double-pointer-use\",\"name\":\"Pointer In C Programming Examples | Double Pointer & Use &#187; CS Taleem\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/cstaleem.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/cstaleem.com\\\/pointer-in-c-programming-examples-double-pointer-use#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/cstaleem.com\\\/pointer-in-c-programming-examples-double-pointer-use#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/cstaleem.com\\\/wp-content\\\/uploads\\\/2024\\\/11\\\/How-Memory-address-is-find-Using-Pointers-in-C.png\",\"datePublished\":\"2024-12-07T14:06:55+00:00\",\"description\":\"A pointer is also a variable that stores the memory address of another variable. The pointer variable itself also contains a memory address.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/cstaleem.com\\\/pointer-in-c-programming-examples-double-pointer-use#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/cstaleem.com\\\/pointer-in-c-programming-examples-double-pointer-use\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/cstaleem.com\\\/pointer-in-c-programming-examples-double-pointer-use#primaryimage\",\"url\":\"https:\\\/\\\/cstaleem.com\\\/wp-content\\\/uploads\\\/2024\\\/11\\\/How-Memory-address-is-find-Using-Pointers-in-C.png\",\"contentUrl\":\"https:\\\/\\\/cstaleem.com\\\/wp-content\\\/uploads\\\/2024\\\/11\\\/How-Memory-address-is-find-Using-Pointers-in-C.png\",\"width\":544,\"height\":243,\"caption\":\"How Memory address is find Using Pointers in C\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/cstaleem.com\\\/pointer-in-c-programming-examples-double-pointer-use#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/cstaleem.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Pointer In C Programming Examples | Double Pointer &#038; Use\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/cstaleem.com\\\/#website\",\"url\":\"https:\\\/\\\/cstaleem.com\\\/\",\"name\":\"CS Taleem\",\"description\":\"CS Higher Education\",\"publisher\":{\"@id\":\"https:\\\/\\\/cstaleem.com\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/cstaleem.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/cstaleem.com\\\/#organization\",\"name\":\"CSTaleem\",\"url\":\"https:\\\/\\\/cstaleem.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/cstaleem.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/cstaleem.com\\\/wp-content\\\/uploads\\\/2021\\\/06\\\/CS-Taleem-Logo.png\",\"contentUrl\":\"https:\\\/\\\/cstaleem.com\\\/wp-content\\\/uploads\\\/2021\\\/06\\\/CS-Taleem-Logo.png\",\"width\":163,\"height\":135,\"caption\":\"CSTaleem\"},\"image\":{\"@id\":\"https:\\\/\\\/cstaleem.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/web.facebook.com\\\/cstaleem\",\"https:\\\/\\\/x.com\\\/saimaltaf15\",\"https:\\\/\\\/www.instagram.com\\\/saimaltaf15\\\/\",\"https:\\\/\\\/www.linkedin.com\\\/in\\\/saimaltaf15\\\/\"],\"publishingPrinciples\":\"https:\\\/\\\/cstaleem.com\\\/become-a-contributer\",\"actionableFeedbackPolicy\":\"https:\\\/\\\/cstaleem.com\\\/corrections-policy-and-practice\",\"correctionsPolicy\":\"https:\\\/\\\/cstaleem.com\\\/corrections-policy-and-practice\",\"ethicsPolicy\":\"https:\\\/\\\/cstaleem.com\\\/our-ethics\",\"diversityPolicy\":\"https:\\\/\\\/cstaleem.com\\\/community-guidelines\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/cstaleem.com\\\/#\\\/schema\\\/person\\\/15225ff8956c5ab2b61229458d540915\",\"name\":\"cst\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/f78249a26495fadc80aae46f8cf9a8f5df74ff072cbd1732aaf8bf05f3926c20?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/f78249a26495fadc80aae46f8cf9a8f5df74ff072cbd1732aaf8bf05f3926c20?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/f78249a26495fadc80aae46f8cf9a8f5df74ff072cbd1732aaf8bf05f3926c20?s=96&d=mm&r=g\",\"caption\":\"cst\"},\"sameAs\":[\"https:\\\/\\\/cstaleem.com\",\"https:\\\/\\\/web.facebook.com\\\/CSTaleem\"]}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Pointer In C Programming Examples | Double Pointer & Use &#187; CS Taleem","description":"A pointer is also a variable that stores the memory address of another variable. The pointer variable itself also contains a memory address.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/cstaleem.com\/pointer-in-c-programming-examples-double-pointer-use","og_locale":"en_US","og_type":"article","og_title":"Pointer In C Programming Examples | Double Pointer & Use","og_description":"A pointer is also a variable that stores the memory address of another variable. The pointer variable itself also contains a memory address.","og_url":"https:\/\/cstaleem.com\/pointer-in-c-programming-examples-double-pointer-use","og_site_name":"CS Taleem","article_publisher":"https:\/\/web.facebook.com\/cstaleem","article_author":"https:\/\/web.facebook.com\/CSTaleem","article_published_time":"2024-12-07T14:06:55+00:00","og_image":[{"url":"https:\/\/cstaleem.com\/wp-content\/uploads\/2024\/11\/How-Memory-address-is-find-Using-Pointers-in-C.png","type":"","width":"","height":""}],"author":"cst","twitter_card":"summary_large_image","twitter_creator":"@saimaltaf15","twitter_site":"@saimaltaf15","twitter_misc":{"Written by":"cst","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/cstaleem.com\/pointer-in-c-programming-examples-double-pointer-use#article","isPartOf":{"@id":"https:\/\/cstaleem.com\/pointer-in-c-programming-examples-double-pointer-use"},"author":{"name":"cst","@id":"https:\/\/cstaleem.com\/#\/schema\/person\/15225ff8956c5ab2b61229458d540915"},"headline":"Pointer In C Programming Examples | Double Pointer &#038; Use","datePublished":"2024-12-07T14:06:55+00:00","mainEntityOfPage":{"@id":"https:\/\/cstaleem.com\/pointer-in-c-programming-examples-double-pointer-use"},"wordCount":403,"commentCount":0,"publisher":{"@id":"https:\/\/cstaleem.com\/#organization"},"image":{"@id":"https:\/\/cstaleem.com\/pointer-in-c-programming-examples-double-pointer-use#primaryimage"},"thumbnailUrl":"https:\/\/cstaleem.com\/wp-content\/uploads\/2024\/11\/How-Memory-address-is-find-Using-Pointers-in-C.png","articleSection":["C Pointers","C Programming"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/cstaleem.com\/pointer-in-c-programming-examples-double-pointer-use#respond"]}]},{"@type":"WebPage","@id":"https:\/\/cstaleem.com\/pointer-in-c-programming-examples-double-pointer-use","url":"https:\/\/cstaleem.com\/pointer-in-c-programming-examples-double-pointer-use","name":"Pointer In C Programming Examples | Double Pointer & Use &#187; CS Taleem","isPartOf":{"@id":"https:\/\/cstaleem.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/cstaleem.com\/pointer-in-c-programming-examples-double-pointer-use#primaryimage"},"image":{"@id":"https:\/\/cstaleem.com\/pointer-in-c-programming-examples-double-pointer-use#primaryimage"},"thumbnailUrl":"https:\/\/cstaleem.com\/wp-content\/uploads\/2024\/11\/How-Memory-address-is-find-Using-Pointers-in-C.png","datePublished":"2024-12-07T14:06:55+00:00","description":"A pointer is also a variable that stores the memory address of another variable. The pointer variable itself also contains a memory address.","breadcrumb":{"@id":"https:\/\/cstaleem.com\/pointer-in-c-programming-examples-double-pointer-use#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/cstaleem.com\/pointer-in-c-programming-examples-double-pointer-use"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/cstaleem.com\/pointer-in-c-programming-examples-double-pointer-use#primaryimage","url":"https:\/\/cstaleem.com\/wp-content\/uploads\/2024\/11\/How-Memory-address-is-find-Using-Pointers-in-C.png","contentUrl":"https:\/\/cstaleem.com\/wp-content\/uploads\/2024\/11\/How-Memory-address-is-find-Using-Pointers-in-C.png","width":544,"height":243,"caption":"How Memory address is find Using Pointers in C"},{"@type":"BreadcrumbList","@id":"https:\/\/cstaleem.com\/pointer-in-c-programming-examples-double-pointer-use#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/cstaleem.com\/"},{"@type":"ListItem","position":2,"name":"Pointer In C Programming Examples | Double Pointer &#038; Use"}]},{"@type":"WebSite","@id":"https:\/\/cstaleem.com\/#website","url":"https:\/\/cstaleem.com\/","name":"CS Taleem","description":"CS Higher Education","publisher":{"@id":"https:\/\/cstaleem.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/cstaleem.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/cstaleem.com\/#organization","name":"CSTaleem","url":"https:\/\/cstaleem.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/cstaleem.com\/#\/schema\/logo\/image\/","url":"https:\/\/cstaleem.com\/wp-content\/uploads\/2021\/06\/CS-Taleem-Logo.png","contentUrl":"https:\/\/cstaleem.com\/wp-content\/uploads\/2021\/06\/CS-Taleem-Logo.png","width":163,"height":135,"caption":"CSTaleem"},"image":{"@id":"https:\/\/cstaleem.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/web.facebook.com\/cstaleem","https:\/\/x.com\/saimaltaf15","https:\/\/www.instagram.com\/saimaltaf15\/","https:\/\/www.linkedin.com\/in\/saimaltaf15\/"],"publishingPrinciples":"https:\/\/cstaleem.com\/become-a-contributer","actionableFeedbackPolicy":"https:\/\/cstaleem.com\/corrections-policy-and-practice","correctionsPolicy":"https:\/\/cstaleem.com\/corrections-policy-and-practice","ethicsPolicy":"https:\/\/cstaleem.com\/our-ethics","diversityPolicy":"https:\/\/cstaleem.com\/community-guidelines"},{"@type":"Person","@id":"https:\/\/cstaleem.com\/#\/schema\/person\/15225ff8956c5ab2b61229458d540915","name":"cst","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/f78249a26495fadc80aae46f8cf9a8f5df74ff072cbd1732aaf8bf05f3926c20?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/f78249a26495fadc80aae46f8cf9a8f5df74ff072cbd1732aaf8bf05f3926c20?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/f78249a26495fadc80aae46f8cf9a8f5df74ff072cbd1732aaf8bf05f3926c20?s=96&d=mm&r=g","caption":"cst"},"sameAs":["https:\/\/cstaleem.com","https:\/\/web.facebook.com\/CSTaleem"]}]}},"_links":{"self":[{"href":"https:\/\/cstaleem.com\/wp-json\/wp\/v2\/posts\/11175","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cstaleem.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cstaleem.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cstaleem.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/cstaleem.com\/wp-json\/wp\/v2\/comments?post=11175"}],"version-history":[{"count":2,"href":"https:\/\/cstaleem.com\/wp-json\/wp\/v2\/posts\/11175\/revisions"}],"predecessor-version":[{"id":11313,"href":"https:\/\/cstaleem.com\/wp-json\/wp\/v2\/posts\/11175\/revisions\/11313"}],"wp:attachment":[{"href":"https:\/\/cstaleem.com\/wp-json\/wp\/v2\/media?parent=11175"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cstaleem.com\/wp-json\/wp\/v2\/categories?post=11175"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cstaleem.com\/wp-json\/wp\/v2\/tags?post=11175"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}