{"id":3398,"date":"2022-11-19T03:32:00","date_gmt":"2022-11-18T22:02:00","guid":{"rendered":"https:\/\/cthecosmos.com\/?p=3398"},"modified":"2022-11-19T03:37:17","modified_gmt":"2022-11-18T22:07:17","slug":"fun-with-pointers","status":"publish","type":"post","link":"https:\/\/cthecosmos.com\/?p=3398","title":{"rendered":"FUN WITH POINTERS"},"content":{"rendered":"\n<p class=\"has-text-color has-background wp-block-paragraph\" style=\"color:#090909;background:linear-gradient(135deg,rgb(238,238,238) 0%,rgb(58,166,190) 48%,rgb(54,153,145) 66%,rgb(169,184,195) 100%);font-size:17px;line-height:1.4;\">Pointers!<br>A confusing yet curious topic.<br><br>What is a <strong>POINTER<\/strong>?<br>Well, it\u2019s a variable that stores the address of another variable.<br><br>We often get confused by the dual operation performed by the pointer.<br>&#8216;<strong>&amp;<\/strong>&#8216; Operator is an address operator that gives the address of a particular variable.<br>&#8216;<strong>*<\/strong>&#8216; Operator is an indirection operator, that refers to the value pointed by the pointer.<br><br>A simple Initialization of a pointer would be:<br><br><strong>int *ptr = NULL;<br>int a = 500;<br>ptr = &amp;a;<\/strong><br><br>Well, that&#8217;s it, the pointer &#8216;<strong>ptr<\/strong>&#8216; now points to the address of <strong>a<\/strong>.<br><br>By using the &#8216;<strong>*<\/strong>&#8216; operation, we can indirectly change the value that is stored in a, ex:<br><strong>*ptr = 1000;<\/strong><br><br>Now the variable &#8216;<strong>a<\/strong>&#8216; has the value <strong>1000<\/strong>.<br><br>Ok, Now let&#8217;s understand how the pointer acts on different types and different types of pointers such as:<br>1) Integer Pointer<br>2) Character Pointer<br>3) Float Pointer<br>4) Double Pointer<br>5) Dangling Pointer<br>6) Wild Pointer<br>7) Null Pointer<br>8) Void Pointer&#8230;<\/p>\n\n\n\n<p class=\"has-text-color has-background wp-block-paragraph\" style=\"color:#070707;background:linear-gradient(135deg,rgb(238,238,238) 21%,rgb(11,58,71) 46%,rgb(169,184,195) 100%);\"><strong>Initializations:<\/strong><br><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\nint main(int argc, char **argv)\n{\n\/\/ Fun with integer variable with different pointer types\nint int_var     =   13 ;\nint *ptr        =   NULL;                  \/\/ A interger pointer\nvoid *void_ptr  =   NULL;                  \/\/ A void pointer\/Generic pointer\n\nint *int_ptr        = NULL;              \/\/ A integer pointer\nchar *char_ptr      = NULL;            \/\/ A character pointer\nfloat *float_ptr    = NULL;          \/\/ A float pointer\ndouble *double_ptr  = NULL;        \/\/ A double pointer\n\n\/\/ Assigning the integer value to different types of pointers\n\nint_ptr     =  &amp;int_var;        \/\/ Integer value to integer pointer\nchar_ptr    =  &amp;int_var;        \/\/ Integer value to character pointer | Should get a warning\nfloat_ptr   =  &amp;int_var;        \/\/ Integer value to float pointer | Should get a warning\ndouble_ptr  =  &amp;int_var;        \/\/ Integer value to double pointer | Should get a warning\n\n\/\/NOTE: %p gives the address \n\n\/\/ Lets print em\n<\/pre><\/div>\n\n\n<p class=\"has-text-color has-background wp-block-paragraph\" style=\"color:#070707;background:linear-gradient(135deg,rgb(238,238,238) 12%,rgb(21,58,39) 66%,rgb(169,184,195) 100%);\"><strong>Starting with Int:<\/strong><br><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\nprintf(&quot;Address of int_var= %p\\n&quot;,&amp;int_var);\n\nprintf(&quot;\\nAddress of the int pointer is %p\\n&quot;,&amp;int_ptr);\nprintf(&quot;\\nAddress of the char pointer is %p\\n&quot;,&amp;char_ptr);\nprintf(&quot;\\nAddress of the float pointer is %p\\n&quot;,&amp;float_ptr);\nprintf(&quot;\\nAddress of the double pointer is %p\\n&quot;,&amp;double_ptr);\n\nprintf(&quot;\\nAddress in the int pointer is %p, Value stored in the pointer is %d\\n&quot;,int_ptr,*int_ptr);\nprintf(&quot;\\nAddress in the char pointer is %p, Value stored in the pointer is %c\\n&quot;,char_ptr,*char_ptr);\nprintf(&quot;\\nAddress in the float pointer is %p, Value stored in the pointer is %f\\n&quot;,float_ptr,*float_ptr);\nprintf(&quot;\\nAddress in the double pointer is %p, Value stored in the pointer is %lf\\n&quot;,double_ptr,*double_ptr);\n\nprintf(&quot;\\n~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~\\n&quot;);\n<\/pre><\/div>\n\n\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"1000\" height=\"449\" data-attachment-id=\"3401\" data-permalink=\"https:\/\/cthecosmos.com\/?attachment_id=3401\" data-orig-file=\"https:\/\/i0.wp.com\/cthecosmos.com\/wp-content\/uploads\/2022\/11\/image-1.png?fit=1195%2C536&amp;ssl=1\" data-orig-size=\"1195,536\" data-comments-opened=\"1\" data-image-title=\"image-1\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/cthecosmos.com\/wp-content\/uploads\/2022\/11\/image-1.png?fit=1000%2C449&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/cthecosmos.com\/wp-content\/uploads\/2022\/11\/image-1.png?resize=1000%2C449&#038;ssl=1\" alt=\"\" class=\"wp-image-3401\" \/><\/figure>\n\n\n\n<p class=\"has-text-color has-background wp-block-paragraph\" style=\"color:#070707;background:linear-gradient(135deg,rgb(238,238,238) 17%,rgb(26,26,4) 57%,rgb(169,184,195) 100%);\"><strong>Now Char:<\/strong><br><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\nchar char_var = &#039;c&#039;;\n\nint_ptr     =  &amp;char_var;        \/\/ Char value to integer pointer | Should get a warning\nchar_ptr    =  &amp;char_var;        \/\/ Char value to character pointer \nfloat_ptr   =  &amp;char_var;        \/\/ Char value to float pointer | Should get a warning\ndouble_ptr  =  &amp;char_var;        \/\/ Char value to double pointer | Should get a warning\n\nprintf(&quot;Address of char_var=  %p\\n&quot;,&amp;char_var);\n\nprintf(&quot;\\nAddress of the int pointer is %p\\n&quot;,&amp;int_ptr);\nprintf(&quot;\\nAddress of the char pointer is %p\\n&quot;,&amp;char_ptr);\nprintf(&quot;\\nAddress of the float pointer is %p\\n&quot;,&amp;float_ptr);\nprintf(&quot;\\nAddress of the double pointer is %p\\n&quot;,&amp;double_ptr);\n\nprintf(&quot;\\nAddress in the int pointer is %p, Value stored in the pointer is %d\\n&quot;,int_ptr,*int_ptr);\nprintf(&quot;\\nAddress in the char pointer is %p, Value stored in the pointer is %c\\n&quot;,char_ptr,*char_ptr);\nprintf(&quot;\\nAddress in the float pointer is %p, Value stored in the pointer is %f\\n&quot;,float_ptr,*float_ptr);\nprintf(&quot;\\nAddress in the double pointer is %p, Value stored in the pointer is %lf\\n&quot;,double_ptr,*double_ptr);\n\nprintf(&quot;\\n~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~\\n&quot;);\n<\/pre><\/div>\n\n\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"1000\" height=\"450\" data-attachment-id=\"3402\" data-permalink=\"https:\/\/cthecosmos.com\/?attachment_id=3402\" data-orig-file=\"https:\/\/i0.wp.com\/cthecosmos.com\/wp-content\/uploads\/2022\/11\/image-2.png?fit=1090%2C490&amp;ssl=1\" data-orig-size=\"1090,490\" data-comments-opened=\"1\" data-image-title=\"image-2\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/cthecosmos.com\/wp-content\/uploads\/2022\/11\/image-2.png?fit=1000%2C450&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/cthecosmos.com\/wp-content\/uploads\/2022\/11\/image-2.png?resize=1000%2C450&#038;ssl=1\" alt=\"\" class=\"wp-image-3402\" \/><\/figure>\n\n\n\n<p class=\"has-text-color has-background wp-block-paragraph\" style=\"color:#070707;background:linear-gradient(135deg,rgb(238,238,238) 0%,rgb(37,24,27) 44%,rgb(169,184,195) 100%);\"><strong>Now to Float:<\/strong><br><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\nfloat float_var = 3.141;\n\nint_ptr     =  &amp;float_var;        \/\/ Float value to integer pointer | Should get a warning\nchar_ptr    =  &amp;float_var;        \/\/ Float value to character pointer | Should get a warning\nfloat_ptr   =  &amp;float_var;        \/\/ Float value to float pointer \ndouble_ptr  =  &amp;float_var;        \/\/ Float value to double pointer | Should get a warning\n\n\nprintf(&quot;Address of float_var=  %p\\n&quot;,&amp;float_var);\n\nprintf(&quot;\\nAddress of the int pointer is %p\\n&quot;,&amp;int_ptr);\nprintf(&quot;\\nAddress of the char pointer is %p\\n&quot;,&amp;char_ptr);\nprintf(&quot;\\nAddress of the float pointer is %p\\n&quot;,&amp;float_ptr);\nprintf(&quot;\\nAddress of the double pointer is %p\\n&quot;,&amp;double_ptr);\n\nprintf(&quot;\\nAddress in the int pointer is %p, Value stored in the pointer is %d\\n&quot;,int_ptr,*int_ptr);\nprintf(&quot;\\nAddress in the char pointer is %p, Value stored in the pointer is %c\\n&quot;,char_ptr,*char_ptr);\nprintf(&quot;\\nAddress in the float pointer is %p, Value stored in the pointer is %f\\n&quot;,float_ptr,*float_ptr);\nprintf(&quot;\\nAddress in the double pointer is %p, Value stored in the pointer is %lf\\n&quot;,double_ptr,*double_ptr);\n\nprintf(&quot;\\n~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~\\n&quot;);\n<\/pre><\/div>\n\n\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"1000\" height=\"420\" data-attachment-id=\"3405\" data-permalink=\"https:\/\/cthecosmos.com\/?attachment_id=3405\" data-orig-file=\"https:\/\/i0.wp.com\/cthecosmos.com\/wp-content\/uploads\/2022\/11\/image-3.png?fit=1090%2C458&amp;ssl=1\" data-orig-size=\"1090,458\" data-comments-opened=\"1\" data-image-title=\"image-3\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/cthecosmos.com\/wp-content\/uploads\/2022\/11\/image-3.png?fit=1000%2C420&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/cthecosmos.com\/wp-content\/uploads\/2022\/11\/image-3.png?resize=1000%2C420&#038;ssl=1\" alt=\"\" class=\"wp-image-3405\" \/><\/figure>\n\n\n\n<p class=\"has-text-color has-background wp-block-paragraph\" style=\"color:#070707;background:linear-gradient(135deg,rgb(238,238,238) 0%,rgb(39,19,64) 57%,rgb(169,184,195) 100%);\"><strong>And Double:<\/strong><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\ndouble double_var = 12365.117784596;\n\nint_ptr     =  &amp;double_var;        \/\/ Double value to integer pointer | Should get a warning\nchar_ptr    =  &amp;double_var;        \/\/ Double value to character pointer | Should get a warning\nfloat_ptr   =  &amp;double_var;        \/\/ Double value to float pointer | Should get a warning\ndouble_ptr  =  &amp;double_var;        \/\/ Double value to double pointer \n\n\nprintf(&quot;Address of double_var=  %p\\n&quot;,&amp;double_var);\n\nprintf(&quot;\\nAddress of the int pointer is %p\\n&quot;,&amp;int_ptr);\nprintf(&quot;\\nAddress of the char pointer is %p\\n&quot;,&amp;char_ptr);\nprintf(&quot;\\nAddress of the float pointer is %p\\n&quot;,&amp;float_ptr);\nprintf(&quot;\\nAddress of the double pointer is %p\\n&quot;,&amp;double_ptr);\n\nprintf(&quot;\\nAddress in the int pointer is %p, Value stored in the pointer is %d\\n&quot;,int_ptr,*int_ptr);\nprintf(&quot;\\nAddress in the char pointer is %p, Value stored in the pointer is %c\\n&quot;,char_ptr,*char_ptr);\nprintf(&quot;\\nAddress in the float pointer is %p, Value stored in the pointer is %f\\n&quot;,float_ptr,*float_ptr);\nprintf(&quot;\\nAddress in the double pointer is %p, Value stored in the pointer is %lf\\n&quot;,double_ptr,*double_ptr);\n\nprintf(&quot;\\n~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~\\n&quot;);\n\n\n\n\/*\nSo you see the effects of wrong type assignment.     \nWrong type casting is dangerous and can lead to breaking of the system. Be careful of the type you are using for the varaible\nMore about void soon.\n*\/\n\n printf(&quot;\\n~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~\\n&quot;);\n\/*\n  Let us check with some different pointer types.\n  1) Wild Pointer\n  2) Dangling Pointer\n  3) NULL Pointer\n  4) Void Pointer\n*\/\n<\/pre><\/div>\n\n\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"1000\" height=\"442\" data-attachment-id=\"3407\" data-permalink=\"https:\/\/cthecosmos.com\/?attachment_id=3407\" data-orig-file=\"https:\/\/i0.wp.com\/cthecosmos.com\/wp-content\/uploads\/2022\/11\/image-4.png?fit=1090%2C482&amp;ssl=1\" data-orig-size=\"1090,482\" data-comments-opened=\"1\" data-image-title=\"image-4\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/cthecosmos.com\/wp-content\/uploads\/2022\/11\/image-4.png?fit=1000%2C442&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/cthecosmos.com\/wp-content\/uploads\/2022\/11\/image-4.png?resize=1000%2C442&#038;ssl=1\" alt=\"\" class=\"wp-image-3407\" \/><\/figure>\n\n\n\n<p class=\"has-text-color has-background wp-block-paragraph\" style=\"color:#070707;background:linear-gradient(135deg,rgb(238,238,238) 0%,rgb(39,133,139) 42%,rgb(169,184,195) 100%);\"><strong>Dangling Pointer:<\/strong><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\n \/\/ A pointer pointing to a location that has been deleted\/freed is known as Dangling Pointer\n\nint *dangling =  NULL ; \/\/ NULL Pointer: Initializing a pointer with NULL is known as NULL pointer\n\/*\n What happens if you de-reference a NULL pointer? Well, its not a good idea as it will lead to Segmentaiton Fault. \n Yeah , don&#039;t dereference a NULL pointer. It is a great practice to check if a pointer is NULL or not before de-referencing it.\n*\/\n\n\/\/printf(&quot;DANGLING POINTER contains the value %d\\n&quot;,*dangling);\n\n\/\/Now with Dangling\nprintf(&quot;\\n~~~~~~~~~~~~~~~~~~~~~  ABOUT DANGLING  ~~~~~~~~~~~~~~~~~~~\\n&quot;);\nif(dangling ==NULL)\n    printf(&quot;\\n\\nWARNING! It is a NULL pointer. Dosen&#039;t contain any address\\n\\n&quot;);\n\ndangling=(int*)malloc(sizeof(int)); \/\/ Initializes memory to store 4 integers\nprintf(&quot;\\nSize of Integer varaiable is : %ld\\n&quot;,sizeof(int));\n\nif(dangling)\nprintf(&quot;\\nSome Random varaibles are stored here. The pointer does have an address where data can be placed\\n&quot;);\nprintf(&quot;The random variable is: %d\\n&quot;,*dangling);\n\n*dangling = 0xffffffff;\nprintf(&quot;Address of value pointed by dangling: %p\\n&quot;,dangling);\nprintf(&quot;Address of value  dangling: %p\\n&quot;,&amp;dangling);\n\nprintf(&quot;\\nValue stored by Dangling Pointer: %x\\n&quot;,*dangling);\n\n<\/pre><\/div>\n\n\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"1000\" height=\"287\" data-attachment-id=\"3408\" data-permalink=\"https:\/\/cthecosmos.com\/?attachment_id=3408\" data-orig-file=\"https:\/\/i0.wp.com\/cthecosmos.com\/wp-content\/uploads\/2022\/11\/image-5.png?fit=1134%2C326&amp;ssl=1\" data-orig-size=\"1134,326\" data-comments-opened=\"1\" data-image-title=\"image-5\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/cthecosmos.com\/wp-content\/uploads\/2022\/11\/image-5.png?fit=1000%2C287&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/cthecosmos.com\/wp-content\/uploads\/2022\/11\/image-5.png?resize=1000%2C287&#038;ssl=1\" alt=\"\" class=\"wp-image-3408\" \/><\/figure>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\n\/\/ What if i do *dangling+1 ? Let&#039;s check\n\nfor(int i=0;i&lt;6;i++)\n{\n    *(dangling+i)=350000+i;\n    printf(&quot;Address  of *(dangling  + %d): %p, Value  stored by *(dangling  + %d) is: %d\\n&quot;,i,(dangling  + i),i,*(dangling+i));\n}\n\n\/\/ Why the above? Lets see by using the free.\n\nfree(dangling);\n\/\/ Once freed, the &quot;dangling&quot; pointer that we declared becomes a Dangling Pointer\n\n\nprintf(&quot;\\nAFTER FREEING:\\n&quot;);\nprintf(&quot;\\nValue stored by Dangling Pointer: %x\\n&quot;,*dangling); \/\/Pointer points to the memory after being freed\n\/\/ free() dosen&#039;t change the value of dangling, but it still points to chuck of memory that malloc() gave.\n\/\/ Now the heap allocator, the one responsible for dynamic memory allocation is ready to give away that location.\n\nfor(int i=0;i&lt;6;i++)\n{\n\n    printf(&quot;Address  of *(dangling  + %d): %p, Value  stored by *(dangling  + %d) is: %d\\n&quot;,i,(dangling  + i),i,*(dangling+i));\n}\n\n\/*  Observed anything? Yep.\n    The starting 4 locations pointed by the pointer are storing garbage value. but the remaining locations store the values that\n    are initialized. But the base pointer is lost once freed, hence it is difficult to get the values from those locations \n    unless they are stored.\n*\/\n<\/pre><\/div>\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"3410\" data-permalink=\"https:\/\/cthecosmos.com\/?attachment_id=3410\" data-orig-file=\"https:\/\/i0.wp.com\/cthecosmos.com\/wp-content\/uploads\/2022\/11\/image-6.png?fit=1107%2C428&amp;ssl=1\" data-orig-size=\"1107,428\" data-comments-opened=\"1\" data-image-title=\"image-6\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/cthecosmos.com\/wp-content\/uploads\/2022\/11\/image-6.png?fit=1000%2C387&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/cthecosmos.com\/wp-content\/uploads\/2022\/11\/image-6.png?resize=692%2C267&#038;ssl=1\" alt=\"\" class=\"wp-image-3410\" width=\"692\" height=\"267\" \/><\/figure>\n\n\n\n<p class=\"has-text-color has-background wp-block-paragraph\" style=\"color:#070707;background:linear-gradient(135deg,rgb(238,238,238) 16%,rgb(42,47,42) 73%,rgb(169,184,195) 100%);\"><strong>About Wild Pointer:<\/strong><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\n\/\/ ~~~~~ ABOUT WILD ~~~~~~~\n\/\/ So now what are wild pointers?\n\/\/ The uninitialized pointers are called as WILD POINTERS\n\n\nint *Wild_ptr;\n\/*Yeah, that&#039;s it. That&#039;s the WILD POINTER. A pointer that is not initialized. \nIf this Wild_ptr is dereferrenced, we will see unexpected behaviour by the compiler, like Segmentation Fault.*\/\n\n\/\/printf(&quot;Address  of Wild_ptr : %p, Value  stored by *(Wild_ptr) is: %d\\n&quot;,Wild_ptr,*(Wild_ptr));\n\/\/ The above gives Seg Fault\n<\/pre><\/div>\n\n\n<p class=\"has-text-color has-background wp-block-paragraph\" style=\"color:#070707;background:linear-gradient(97deg,rgb(238,238,238) 0%,rgb(181,164,164) 10%,rgb(58,50,50) 34%,rgb(169,184,195) 100%);\"><strong>About Void:<\/strong><br><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\nprintf(&quot;\\n~~~~~ ABOUT VOID ~~~~~~~\\n&quot;);\n\/\/Now let us look at void pointer\nint_var = 215;\n\n void_ptr    =  &amp;int_var;      \/\/   Integer value to void pointer | ERROR! *\/\n \/\/void_ptr    =  &amp;char_var;      \/\/   Char value to void pointer | ERROR! *\/\n \/\/void_ptr    =  &amp;float_var;      \/\/ Float value to void pointer | ERROR! *\/\n \/\/void_ptr    =  &amp;double_var;      \/\/ Double value to void pointer | ERROR! *\/\n\n\/\/printf(&quot;\\nVoid pointer address is: %p, Value stored in the pointer is %d\\n&quot;,*void_ptr); \n\/\/ The above statement should give error as it is a must to externally type cast void pointer    \n\n\/\/ You can either type cast it where it is being used or you can type cast it during initialization\n\nprintf(&quot;\\nVoid pointer(int *) address is: %p, Value stored in the pointer is %d\\n&quot;,void_ptr,*((int *)void_ptr)); \n\/\/ The above statement would be the right use of void pointer\n\n\/\/ What if the external type casting is wrong for void pointer?\n\/\/ Lets find out\nprintf(&quot;\\nVoid pointer(char *) address is: %p, Value stored in the pointer is %c\\n&quot;,void_ptr,*((char *)void_ptr)); \nprintf(&quot;\\nVoid pointer(float *) address is: %p, Value stored in the pointer is %f\\n&quot;,void_ptr,*((float *)void_ptr)); \nprintf(&quot;\\nVoid pointer(double *) address is: %p, Value stored in the pointer is %lf\\n&quot;,void_ptr,*((double *)void_ptr)); \n\n<\/pre><\/div>\n\n\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"1000\" height=\"195\" data-attachment-id=\"3412\" data-permalink=\"https:\/\/cthecosmos.com\/?attachment_id=3412\" data-orig-file=\"https:\/\/i0.wp.com\/cthecosmos.com\/wp-content\/uploads\/2022\/11\/image-7.png?fit=1382%2C269&amp;ssl=1\" data-orig-size=\"1382,269\" data-comments-opened=\"1\" data-image-title=\"image-7\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/cthecosmos.com\/wp-content\/uploads\/2022\/11\/image-7.png?fit=1000%2C195&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/cthecosmos.com\/wp-content\/uploads\/2022\/11\/image-7.png?resize=1000%2C195&#038;ssl=1\" alt=\"\" class=\"wp-image-3412\" \/><\/figure>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\n\n\/\/ THE TRUE WAY TO USE THE %p. Use it with generic pointer and a good use of void pointer is as below\nvoid *true_ptr = NULL;\nint some_int_val = 10;\nchar some_char_val = &#039;1&#039;;\nfloat some_float_val = 3.141;\ndouble some_double_val  = 3.14159265358979;\n\ntrue_ptr = &amp;some_int_val;\nprintf(&quot;\\nAddress of true_ptr is: %p, Address pointed by true_ptr: %p, Value in  true_ptr:%d \\n&quot;, \n&amp;true_ptr,  true_ptr, *((int*)true_ptr));    \n\ntrue_ptr = &amp;some_char_val;\nprintf(&quot;\\nAddress of true_ptr is: %p, Address pointed by true_ptr: %p, Value in  true_ptr:%c \\n&quot;, \n&amp;true_ptr,  true_ptr, *((char*)true_ptr));    \n\ntrue_ptr =  &amp;some_float_val;\nprintf(&quot;\\nAddress of true_ptr is: %p, Address pointed by true_ptr: %p, Value in  true_ptr:%f \\n&quot;, \n&amp;true_ptr,  true_ptr, *((float*)true_ptr));    \n\ntrue_ptr = &amp;some_double_val;\nprintf(&quot;\\nAddress of true_ptr is: %p, Address pointed by true_ptr: %p, Value in  true_ptr:%lf \\n&quot;, \n&amp;true_ptr,  true_ptr, *((double*)true_ptr));    \n\n\/* As you can see in the output, the same pointer is pointing to different address.\n Yeah, a void pointer can be used to derefence any pointer type.*\/\nreturn 0;\n}\n<\/pre><\/div>\n\n\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"1000\" height=\"170\" data-attachment-id=\"3413\" data-permalink=\"https:\/\/cthecosmos.com\/?attachment_id=3413\" data-orig-file=\"https:\/\/i0.wp.com\/cthecosmos.com\/wp-content\/uploads\/2022\/11\/image-8.png?fit=1566%2C266&amp;ssl=1\" data-orig-size=\"1566,266\" data-comments-opened=\"1\" data-image-title=\"image-8\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/cthecosmos.com\/wp-content\/uploads\/2022\/11\/image-8.png?fit=1000%2C170&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/cthecosmos.com\/wp-content\/uploads\/2022\/11\/image-8.png?resize=1000%2C170&#038;ssl=1\" alt=\"\" class=\"wp-image-3413\" \/><\/figure>\n\n\n\n<p class=\"has-white-color has-text-color has-background wp-block-paragraph\" style=\"background-color:#222729;\">CAME THIS FAR? Why not go ahead with Dynamic Memory Allocation?<br>Well, there are just a few handfull of Dynamic Mem functions.<br>1) MALLOC<br>2) CALLOC<br>3) REALLOC<br>4) FREE<br>Let us take that up in another post.<\/p>\n\n\n\n<p class=\"has-blush-bordeaux-gradient-background has-text-color has-background wp-block-paragraph\" style=\"color:#070707;\"><strong>Stay Tuned, See you Soon .<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Page Image credit: Reddit<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Pointers!A confusing yet curious topic. What is a POINTER?Well, it\u2019s a variable that stores the address of another variable. We often get confused by the dual operation performed by the pointer.&#8216;&amp;&#8216; Operator is an address operator that gives the address of a particular variable.&#8216;*&#8216; Operator is an indirection operator, that refers to the value pointed [&hellip;]<\/p>\n<a href=\"https:\/\/cthecosmos.com\/?p=3398\" class=\"more-link\">Read More <span class=\"screen-reader-text\">FUN WITH POINTERS<\/span><\/a>","protected":false},"author":120055267,"featured_media":3420,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_wpcom_ai_launchpad_first_post":false,"_jetpack_hide_featured_image":false,"_jetpack_featured_image_duplicate_dismissed":0,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"{title}\n\n{excerpt}\n\n{url}","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"_wpas_customize_per_network":false,"jetpack_post_was_ever_published":false},"categories":[1342,28627],"tags":[2426,772321181,22341966,772321191,116003636,264,20863,196,5198471],"class_list":["post-3398","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-education","category-embedded","tag-c","tag-education","tag-embd","tag-embedded","tag-embedded-c-2","tag-learning","tag-pointers","tag-programming","tag-segmentation-fault","fallback-thumbnail"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 5.0.4 - aioseo.com -->\n\t<meta name=\"description\" content=\"Pointers!A confusing yet curious topic.What is a POINTER?Well, it\u2019s a variable that stores the address of another variable.We often get confused by the dual operation performed by the pointer.&#039;&amp;&#039; Operator is an address operator that gives the address of a particular variable.&#039;*&#039; Operator is an indirection operator, that refers to the value pointed by the\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"Yashwanth Naidu Tikkisetty\"\/>\n\t<link rel=\"canonical\" href=\"https:\/\/cthecosmos.com\/?p=3398\" \/>\n\t\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.4\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_US\" \/>\n\t\t<meta property=\"og:site_name\" content=\"Yashwanth Naidu Tikkisetty - Embedded Systems | Space Blogger\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"FUN WITH POINTERS - Yashwanth Naidu Tikkisetty\" \/>\n\t\t<meta property=\"og:description\" content=\"Pointers!A confusing yet curious topic.What is a POINTER?Well, it\u2019s a variable that stores the address of another variable.We often get confused by the dual operation performed by the pointer.&#039;&amp;&#039; Operator is an address operator that gives the address of a particular variable.&#039;*&#039; Operator is an indirection operator, that refers to the value pointed by the\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/cthecosmos.com\/?p=3398\" \/>\n\t\t<meta property=\"og:image\" content=\"https:\/\/cthecosmos.com\/wp-content\/uploads\/2018\/08\/logo1.png\" \/>\n\t\t<meta property=\"og:image:secure_url\" content=\"https:\/\/cthecosmos.com\/wp-content\/uploads\/2018\/08\/logo1.png\" \/>\n\t\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t\t<meta property=\"og:image:height\" content=\"1200\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2022-11-18T22:02:00+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2022-11-18T22:07:17+00:00\" \/>\n\t\t<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n\t\t<meta name=\"twitter:title\" content=\"FUN WITH POINTERS - Yashwanth Naidu Tikkisetty\" \/>\n\t\t<meta name=\"twitter:description\" content=\"Pointers!A confusing yet curious topic.What is a POINTER?Well, it\u2019s a variable that stores the address of another variable.We often get confused by the dual operation performed by the pointer.&#039;&amp;&#039; Operator is an address operator that gives the address of a particular variable.&#039;*&#039; Operator is an indirection operator, that refers to the value pointed by the\" \/>\n\t\t<meta name=\"twitter:image\" content=\"https:\/\/cthecosmos.com\/wp-content\/uploads\/2018\/08\/logo1.png\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"BlogPosting\",\"@id\":\"https:\\\/\\\/cthecosmos.com\\\/?p=3398#blogposting\",\"name\":\"FUN WITH POINTERS - Yashwanth Naidu Tikkisetty\",\"headline\":\"FUN WITH POINTERS\",\"author\":{\"@id\":\"https:\\\/\\\/cthecosmos.com\\\/?author=120055267#author\"},\"publisher\":{\"@id\":\"https:\\\/\\\/cthecosmos.com\\\/#person\"},\"image\":{\"@type\":\"ImageObject\",\"url\":\"https:\\\/\\\/i0.wp.com\\\/cthecosmos.com\\\/wp-content\\\/uploads\\\/2022\\\/11\\\/pointer-839149736-e1668808902776.png?fit=1138%2C831&ssl=1\",\"width\":1138,\"height\":831},\"datePublished\":\"2022-11-19T03:32:00+05:30\",\"dateModified\":\"2022-11-19T03:37:17+05:30\",\"inLanguage\":\"en-US\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/cthecosmos.com\\\/?p=3398#webpage\"},\"isPartOf\":{\"@id\":\"https:\\\/\\\/cthecosmos.com\\\/?p=3398#webpage\"},\"articleSection\":\"Education, Embedded, C, Education, embd, Embedded, Embedded C, learning, pointers, Programming, Segmentation fault\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/cthecosmos.com\\\/?p=3398#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/cthecosmos.com\\\/#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/cthecosmos.com\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/cthecosmos.com\\\/?cat=1342#listItem\",\"name\":\"Education\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/cthecosmos.com\\\/?cat=1342#listItem\",\"position\":2,\"name\":\"Education\",\"item\":\"https:\\\/\\\/cthecosmos.com\\\/?cat=1342\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/cthecosmos.com\\\/?p=3398#listItem\",\"name\":\"FUN WITH POINTERS\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/cthecosmos.com\\\/#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/cthecosmos.com\\\/?p=3398#listItem\",\"position\":3,\"name\":\"FUN WITH POINTERS\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/cthecosmos.com\\\/?cat=1342#listItem\",\"name\":\"Education\"}}]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/cthecosmos.com\\\/#person\",\"name\":\"Yashwanth Naidu Tikkisetty\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/cthecosmos.com\\\/?p=3398#personImage\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/a02d9f38e4c924587b544c74f6d5de0c8469b6a5c684622f1aa4ea2ba65b17d8?s=96&d=identicon&r=g\",\"width\":96,\"height\":96,\"caption\":\"Yashwanth Naidu Tikkisetty\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/cthecosmos.com\\\/?author=120055267#author\",\"url\":\"https:\\\/\\\/cthecosmos.com\\\/?author=120055267\",\"name\":\"Yashwanth Naidu Tikkisetty\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/cthecosmos.com\\\/?p=3398#authorImage\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/a02d9f38e4c924587b544c74f6d5de0c8469b6a5c684622f1aa4ea2ba65b17d8?s=96&d=identicon&r=g\",\"width\":96,\"height\":96,\"caption\":\"Yashwanth Naidu Tikkisetty\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/cthecosmos.com\\\/?p=3398#webpage\",\"url\":\"https:\\\/\\\/cthecosmos.com\\\/?p=3398\",\"name\":\"FUN WITH POINTERS - Yashwanth Naidu Tikkisetty\",\"description\":\"Pointers!A confusing yet curious topic.What is a POINTER?Well, it\\u2019s a variable that stores the address of another variable.We often get confused by the dual operation performed by the pointer.'&' Operator is an address operator that gives the address of a particular variable.'*' Operator is an indirection operator, that refers to the value pointed by the\",\"inLanguage\":\"en-US\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/cthecosmos.com\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/cthecosmos.com\\\/?p=3398#breadcrumblist\"},\"author\":{\"@id\":\"https:\\\/\\\/cthecosmos.com\\\/?author=120055267#author\"},\"creator\":{\"@id\":\"https:\\\/\\\/cthecosmos.com\\\/?author=120055267#author\"},\"image\":{\"@type\":\"ImageObject\",\"url\":\"https:\\\/\\\/i0.wp.com\\\/cthecosmos.com\\\/wp-content\\\/uploads\\\/2022\\\/11\\\/pointer-839149736-e1668808902776.png?fit=1138%2C831&ssl=1\",\"@id\":\"https:\\\/\\\/cthecosmos.com\\\/?p=3398\\\/#mainImage\",\"width\":1138,\"height\":831},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/cthecosmos.com\\\/?p=3398#mainImage\"},\"datePublished\":\"2022-11-19T03:32:00+05:30\",\"dateModified\":\"2022-11-19T03:37:17+05:30\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/cthecosmos.com\\\/#website\",\"url\":\"https:\\\/\\\/cthecosmos.com\\\/\",\"name\":\"Yashwanth Naidu Tikkisetty\",\"description\":\"Embedded Systems | Space Blogger\",\"inLanguage\":\"en-US\",\"publisher\":{\"@id\":\"https:\\\/\\\/cthecosmos.com\\\/#person\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"FUN WITH POINTERS - Yashwanth Naidu Tikkisetty","description":"Pointers!A confusing yet curious topic.What is a POINTER?Well, it\u2019s a variable that stores the address of another variable.We often get confused by the dual operation performed by the pointer.'&' Operator is an address operator that gives the address of a particular variable.'*' Operator is an indirection operator, that refers to the value pointed by the","canonical_url":"https:\/\/cthecosmos.com\/?p=3398","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"BlogPosting","@id":"https:\/\/cthecosmos.com\/?p=3398#blogposting","name":"FUN WITH POINTERS - Yashwanth Naidu Tikkisetty","headline":"FUN WITH POINTERS","author":{"@id":"https:\/\/cthecosmos.com\/?author=120055267#author"},"publisher":{"@id":"https:\/\/cthecosmos.com\/#person"},"image":{"@type":"ImageObject","url":"https:\/\/i0.wp.com\/cthecosmos.com\/wp-content\/uploads\/2022\/11\/pointer-839149736-e1668808902776.png?fit=1138%2C831&ssl=1","width":1138,"height":831},"datePublished":"2022-11-19T03:32:00+05:30","dateModified":"2022-11-19T03:37:17+05:30","inLanguage":"en-US","mainEntityOfPage":{"@id":"https:\/\/cthecosmos.com\/?p=3398#webpage"},"isPartOf":{"@id":"https:\/\/cthecosmos.com\/?p=3398#webpage"},"articleSection":"Education, Embedded, C, Education, embd, Embedded, Embedded C, learning, pointers, Programming, Segmentation fault"},{"@type":"BreadcrumbList","@id":"https:\/\/cthecosmos.com\/?p=3398#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/cthecosmos.com\/#listItem","position":1,"name":"Home","item":"https:\/\/cthecosmos.com\/","nextItem":{"@type":"ListItem","@id":"https:\/\/cthecosmos.com\/?cat=1342#listItem","name":"Education"}},{"@type":"ListItem","@id":"https:\/\/cthecosmos.com\/?cat=1342#listItem","position":2,"name":"Education","item":"https:\/\/cthecosmos.com\/?cat=1342","nextItem":{"@type":"ListItem","@id":"https:\/\/cthecosmos.com\/?p=3398#listItem","name":"FUN WITH POINTERS"},"previousItem":{"@type":"ListItem","@id":"https:\/\/cthecosmos.com\/#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/cthecosmos.com\/?p=3398#listItem","position":3,"name":"FUN WITH POINTERS","previousItem":{"@type":"ListItem","@id":"https:\/\/cthecosmos.com\/?cat=1342#listItem","name":"Education"}}]},{"@type":"Person","@id":"https:\/\/cthecosmos.com\/#person","name":"Yashwanth Naidu Tikkisetty","image":{"@type":"ImageObject","@id":"https:\/\/cthecosmos.com\/?p=3398#personImage","url":"https:\/\/secure.gravatar.com\/avatar\/a02d9f38e4c924587b544c74f6d5de0c8469b6a5c684622f1aa4ea2ba65b17d8?s=96&d=identicon&r=g","width":96,"height":96,"caption":"Yashwanth Naidu Tikkisetty"}},{"@type":"Person","@id":"https:\/\/cthecosmos.com\/?author=120055267#author","url":"https:\/\/cthecosmos.com\/?author=120055267","name":"Yashwanth Naidu Tikkisetty","image":{"@type":"ImageObject","@id":"https:\/\/cthecosmos.com\/?p=3398#authorImage","url":"https:\/\/secure.gravatar.com\/avatar\/a02d9f38e4c924587b544c74f6d5de0c8469b6a5c684622f1aa4ea2ba65b17d8?s=96&d=identicon&r=g","width":96,"height":96,"caption":"Yashwanth Naidu Tikkisetty"}},{"@type":"WebPage","@id":"https:\/\/cthecosmos.com\/?p=3398#webpage","url":"https:\/\/cthecosmos.com\/?p=3398","name":"FUN WITH POINTERS - Yashwanth Naidu Tikkisetty","description":"Pointers!A confusing yet curious topic.What is a POINTER?Well, it\u2019s a variable that stores the address of another variable.We often get confused by the dual operation performed by the pointer.'&' Operator is an address operator that gives the address of a particular variable.'*' Operator is an indirection operator, that refers to the value pointed by the","inLanguage":"en-US","isPartOf":{"@id":"https:\/\/cthecosmos.com\/#website"},"breadcrumb":{"@id":"https:\/\/cthecosmos.com\/?p=3398#breadcrumblist"},"author":{"@id":"https:\/\/cthecosmos.com\/?author=120055267#author"},"creator":{"@id":"https:\/\/cthecosmos.com\/?author=120055267#author"},"image":{"@type":"ImageObject","url":"https:\/\/i0.wp.com\/cthecosmos.com\/wp-content\/uploads\/2022\/11\/pointer-839149736-e1668808902776.png?fit=1138%2C831&ssl=1","@id":"https:\/\/cthecosmos.com\/?p=3398\/#mainImage","width":1138,"height":831},"primaryImageOfPage":{"@id":"https:\/\/cthecosmos.com\/?p=3398#mainImage"},"datePublished":"2022-11-19T03:32:00+05:30","dateModified":"2022-11-19T03:37:17+05:30"},{"@type":"WebSite","@id":"https:\/\/cthecosmos.com\/#website","url":"https:\/\/cthecosmos.com\/","name":"Yashwanth Naidu Tikkisetty","description":"Embedded Systems | Space Blogger","inLanguage":"en-US","publisher":{"@id":"https:\/\/cthecosmos.com\/#person"}}]},"og:locale":"en_US","og:site_name":"Yashwanth Naidu Tikkisetty - Embedded Systems | Space Blogger","og:type":"article","og:title":"FUN WITH POINTERS - Yashwanth Naidu Tikkisetty","og:description":"Pointers!A confusing yet curious topic.What is a POINTER?Well, it\u2019s a variable that stores the address of another variable.We often get confused by the dual operation performed by the pointer.'&amp;' Operator is an address operator that gives the address of a particular variable.'*' Operator is an indirection operator, that refers to the value pointed by the","og:url":"https:\/\/cthecosmos.com\/?p=3398","og:image":"https:\/\/cthecosmos.com\/wp-content\/uploads\/2018\/08\/logo1.png","og:image:secure_url":"https:\/\/cthecosmos.com\/wp-content\/uploads\/2018\/08\/logo1.png","og:image:width":1200,"og:image:height":1200,"article:published_time":"2022-11-18T22:02:00+00:00","article:modified_time":"2022-11-18T22:07:17+00:00","twitter:card":"summary_large_image","twitter:title":"FUN WITH POINTERS - Yashwanth Naidu Tikkisetty","twitter:description":"Pointers!A confusing yet curious topic.What is a POINTER?Well, it\u2019s a variable that stores the address of another variable.We often get confused by the dual operation performed by the pointer.'&amp;' Operator is an address operator that gives the address of a particular variable.'*' Operator is an indirection operator, that refers to the value pointed by the","twitter:image":"https:\/\/cthecosmos.com\/wp-content\/uploads\/2018\/08\/logo1.png"},"aioseo_meta_data":{"post_id":"3398","title":null,"description":null,"keywords":null,"keyphrases":null,"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":null,"og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"","isEnabled":true},"graphs":[]},"schema_type":"default","schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"local_seo":null,"breadcrumb_settings":null,"limit_modified_date":false,"ai":null,"created":"2025-08-31 20:13:00","updated":"2025-08-31 20:13:00","seo_analyzer_scan_date":null,"focus_keyword":null,"additional_keywords":null,"truseo_locale":null},"aioseo_breadcrumb":"<div class=\"aioseo-breadcrumbs\"><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/cthecosmos.com\/\" title=\"Home\">Home<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">\u00bb<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/cthecosmos.com\/?cat=1342\" title=\"Education\">Education<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">\u00bb<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\tFUN WITH POINTERS\n\t\t<\/span><\/div>","aioseo_breadcrumb_json":[{"label":"Home","link":"https:\/\/cthecosmos.com\/"},{"label":"Education","link":"https:\/\/cthecosmos.com\/?cat=1342"},{"label":"FUN WITH POINTERS","link":"https:\/\/cthecosmos.com\/?p=3398"}],"jetpack_publicize_connections":[],"jetpack_likes_enabled":true,"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p8CiEf-SO","jetpack-related-posts":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/cthecosmos.com\/wp-content\/uploads\/2022\/11\/pointer-839149736-e1668808902776.png?fit=1138%2C831&ssl=1","_links":{"self":[{"href":"https:\/\/cthecosmos.com\/index.php?rest_route=\/wp\/v2\/posts\/3398","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cthecosmos.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cthecosmos.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cthecosmos.com\/index.php?rest_route=\/wp\/v2\/users\/120055267"}],"replies":[{"embeddable":true,"href":"https:\/\/cthecosmos.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3398"}],"version-history":[{"count":19,"href":"https:\/\/cthecosmos.com\/index.php?rest_route=\/wp\/v2\/posts\/3398\/revisions"}],"predecessor-version":[{"id":3426,"href":"https:\/\/cthecosmos.com\/index.php?rest_route=\/wp\/v2\/posts\/3398\/revisions\/3426"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/cthecosmos.com\/index.php?rest_route=\/wp\/v2\/media\/3420"}],"wp:attachment":[{"href":"https:\/\/cthecosmos.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3398"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cthecosmos.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3398"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cthecosmos.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3398"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}