<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: julio</title>
    <description>The latest articles on DEV Community by julio (@jcesargm).</description>
    <link>https://dev.to/jcesargm</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1242887%2Fcb1e1ded-db40-4663-99ee-2e983b9f60b2.png</url>
      <title>DEV Community: julio</title>
      <link>https://dev.to/jcesargm</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/jcesargm"/>
    <language>en</language>
    <item>
      <title>Pointer in C</title>
      <dc:creator>julio</dc:creator>
      <pubDate>Tue, 20 Feb 2024 12:39:44 +0000</pubDate>
      <link>https://dev.to/jcesargm/pointer-in-c-497f</link>
      <guid>https://dev.to/jcesargm/pointer-in-c-497f</guid>
      <description>&lt;h2&gt;
  
  
  0. What are pointers?
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;Pointer&lt;/em&gt; is a data type that stores a memory address of a variable type. Pointers are widely used in C to handle data structures, dynamically allocate memory, and optimize performance in certain situations.&lt;/p&gt;

&lt;p&gt;Every variable is associated with three things: datatype, name, value and address, that are stored in memory. We can easily access the address, using &amp;amp; before variable. Below is how we can see a address of a variable in C:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;int variable = 2;
printf("The address of variable = %p.\n", &amp;amp;variable);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The function of pointer how i said above is store the address of a determinate variable, in code it works like that:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;int *pointer = &amp;amp;variable;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;or&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;int *pointer;
pointer = &amp;amp;variable;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When the pointer points nowhere, we give it the value null.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;int *pointer2 = NULL;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To see if the pointer is really storing the address of the variable we do another printf to check, and now we just have to see if the addresses are the same.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;printf("The address that the pointer stores: = %p.\n", pointer);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we can access the value of the "variable" through the pointer thereby using *: (*pointer)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;printf("Value of variable: %d || Value of variable through pointer: %d\n", variable, *pointer);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>c</category>
      <category>datastructures</category>
      <category>pointer</category>
      <category>lowcode</category>
    </item>
  </channel>
</rss>
