<?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: Yarakaraju Jahnavi</title>
    <description>The latest articles on DEV Community by Yarakaraju Jahnavi (@jahnavi1351).</description>
    <link>https://dev.to/jahnavi1351</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%2F629036%2Fa285563c-5c06-4ca3-8d5e-df7cb51ff42a.png</url>
      <title>DEV Community: Yarakaraju Jahnavi</title>
      <link>https://dev.to/jahnavi1351</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/jahnavi1351"/>
    <language>en</language>
    <item>
      <title>POINTERS IN C</title>
      <dc:creator>Yarakaraju Jahnavi</dc:creator>
      <pubDate>Thu, 25 Nov 2021 17:46:44 +0000</pubDate>
      <link>https://dev.to/jahnavi1351/pointers-in-c-5bp6</link>
      <guid>https://dev.to/jahnavi1351/pointers-in-c-5bp6</guid>
      <description>&lt;p&gt;&lt;strong&gt;POINTERS IN C&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;•Every variable is a memory location and every memory location has its address defined which can be accessed using ampersand (&amp;amp;) operator, which denotes an address in memory.&lt;/p&gt;

&lt;p&gt;• A pointer is a variable whose value is the address of another variable, i.e., direct address of the memory location. Like any variable or constant, you must declare a pointer before using it to store any variable address.&lt;/p&gt;

&lt;p&gt;• The general form of a pointer variable declaration is:&lt;br&gt;
type *var-name;&lt;/p&gt;

&lt;p&gt;Here,&lt;br&gt;
   -- type is the pointer's base type (it must be a valid C&lt;br&gt;
      datatype).&lt;br&gt;
   -- var-name is the name of the pointer variable.&lt;br&gt;
   -- * used to declare a pointer.&lt;/p&gt;

&lt;p&gt;• Some of the valid pointer declarations are as follows −&lt;br&gt;
   int ip; / pointer to an integer /&lt;br&gt;
   double *dp; / pointer to a double /&lt;br&gt;
   float *fp; / pointer to a float /&lt;br&gt;
   char *ch / pointer to a character */&lt;/p&gt;

&lt;p&gt;• The actual data type of the value of all pointers, whether &lt;br&gt;
integer, float, character, or otherwise, is the same, a long hexadecimal number that represents a memory address. The only difference between pointers of different data types is the data type of the variable or constant that the pointer points to.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;USAGE OF POINTERS&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;(a) We define a pointer variable.&lt;br&gt;
(b) Assign the address of a variable to a pointer.&lt;br&gt;
(c) Finally access the value at the address available in the pointer variable.&lt;/p&gt;

&lt;p&gt;• This is done by using unary operator * that returns the value of the variable located at the address specified by its operand.&lt;/p&gt;

&lt;p&gt;• &lt;em&gt;Example:&lt;/em&gt;&lt;br&gt;
   #include&lt;br&gt;
   int main ()&lt;br&gt;
   {&lt;br&gt;
   int var = 20; /* actual variable declaration /&lt;br&gt;
   int &lt;em&gt;ip; / pointer variable declaration /&lt;br&gt;
   ip = &amp;amp;var; / store address of var in pointer variable&lt;/em&gt;/&lt;br&gt;
   printf("Address of var variable: %x\n", &amp;amp;var );&lt;br&gt;
   /* address stored in pointer variable /&lt;br&gt;
   printf("Address stored in ip variable: %x\n", ip );&lt;br&gt;
   / access the value using the pointer */&lt;br&gt;
   printf("Value of *ip variable: %d\n", *ip );&lt;br&gt;
   return 0;&lt;br&gt;
   }&lt;/p&gt;

&lt;p&gt;• When the above code is compiled and executed, it produces the following result −&lt;br&gt;
   -- Address of var variable: bffd8b3c&lt;br&gt;
   -- Address stored in ip variable: bffd8b3c&lt;br&gt;
   -- Value of *ip variable: 20&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;NULL POINTERS&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;• It is always a good practice to assign a NULL value to a pointer variable in case you do not have an exact address to be assigned. This is done at the time of variable declaration. A pointer that is assigned NULL is called a null pointer.&lt;/p&gt;

&lt;p&gt;• The NULL pointer is a constant with a value of zero defined in several standard libraries. Consider the following program −&lt;/p&gt;

&lt;p&gt;• &lt;em&gt;Example:&lt;/em&gt;&lt;br&gt;
   #include&lt;br&gt;
   int main ()&lt;br&gt;
   {&lt;br&gt;
   int *ptr = NULL;&lt;br&gt;
   printf("The value of ptr is : %x\n", ptr );&lt;br&gt;
   return 0;&lt;br&gt;
   }&lt;/p&gt;

&lt;p&gt;• When the above code is compiled and executed, it produces the following result −&lt;br&gt;
   -- The value of ptr is 0&lt;br&gt;
   -- In most of the operating systems, programs are not permitted&lt;br&gt;
      to access memory at address 0 because that memory is &lt;br&gt;
      reserved by the operating system.&lt;br&gt;
   -- However, the memory address 0 has special significance; it&lt;br&gt;
      signals that the pointer is not intended to point to an&lt;br&gt;
      accessible memory location. But by convention, if a pointer&lt;br&gt;
      contains the null (zero) value, it is assumed to point to&lt;br&gt;
      nothing.&lt;br&gt;
   -- To check for a null pointer, you can use an 'if' statement &lt;br&gt;
      as follows −&lt;br&gt;
         if(ptr)     /* succeeds if p is not null &lt;em&gt;/&lt;br&gt;
         if(!ptr)    /&lt;/em&gt; succeeds if p is null */&lt;/p&gt;

</description>
      <category>computerscience</category>
      <category>coding</category>
      <category>c</category>
      <category>ptr</category>
    </item>
    <item>
      <title>POINTERS IN C-LANGUAGE</title>
      <dc:creator>Yarakaraju Jahnavi</dc:creator>
      <pubDate>Tue, 11 May 2021 14:02:29 +0000</pubDate>
      <link>https://dev.to/jahnavi1351/pointers-in-c-language-4oie</link>
      <guid>https://dev.to/jahnavi1351/pointers-in-c-language-4oie</guid>
      <description>&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;                       POINTERS IN C
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;•Every variable is a memory location and every memory location has its address defined which can be accessed using ampersand (&amp;amp;) operator, which denotes an address in memory.&lt;/p&gt;

&lt;p&gt;•A pointer is a variable whose value is the address of another variable, i.e., direct address of the memory location. Like any variable or constant, you must declare a pointer before using it to store any variable address.&lt;/p&gt;

&lt;p&gt;•The general form of a pointer variable declaration is:&lt;br&gt;
    type *var-name;&lt;/p&gt;

&lt;p&gt;Here,&lt;br&gt;
   -- type is the pointer's base type (it must be a valid C &lt;br&gt;
      datatype).&lt;br&gt;
   -- var-name is the name of the pointer variable.&lt;br&gt;
   -- * used to declare a pointer.&lt;/p&gt;

&lt;p&gt;•Some of the valid pointer declarations are as follows −&lt;br&gt;
    int    &lt;em&gt;ip;          /&lt;/em&gt; pointer to an integer &lt;em&gt;/&lt;br&gt;
    double *dp;    /&lt;/em&gt; pointer to a double &lt;em&gt;/&lt;br&gt;
    float  *fp;        /&lt;/em&gt; pointer to a float &lt;em&gt;/&lt;br&gt;
    char   *ch        /&lt;/em&gt; pointer to a character */&lt;/p&gt;

&lt;p&gt;•The actual data type of the value of all pointers, whether integer, float, character, or otherwise, is the same, a long hexadecimal number that represents a memory address. The only difference between pointers of different data types is the data type of the variable or constant that the pointer points to.&lt;/p&gt;

&lt;p&gt;USAGE OF POINTERS:&lt;/p&gt;

&lt;p&gt;(a) We define a pointer variable.&lt;br&gt;
(b) Assign the address of a variable to a pointer.&lt;br&gt;
(c) Finally access the value at the address available in the pointer variable.&lt;br&gt;
•This is done by using unary operator * that returns the value of the variable located at the address specified by its operand.&lt;br&gt;
•Example:&lt;br&gt;
   #include &lt;br&gt;
   int main () &lt;br&gt;
   {&lt;br&gt;
     int  var = 20;   /* actual variable declaration &lt;em&gt;/&lt;br&gt;
     int  *ip;        /&lt;/em&gt; pointer variable declaration &lt;em&gt;/&lt;br&gt;
     ip = &amp;amp;var;  /&lt;/em&gt; store address of var in pointer variable*/&lt;br&gt;
     printf("Address of var variable: %x\n", &amp;amp;var  );&lt;br&gt;
        /* address stored in pointer variable &lt;em&gt;/&lt;br&gt;
     printf("Address stored in ip variable: %x\n", ip );&lt;br&gt;
     /&lt;/em&gt; access the value using the pointer */&lt;br&gt;
     printf("Value of *ip variable: %d\n", *ip );&lt;br&gt;
     return 0;&lt;br&gt;
   }&lt;/p&gt;

&lt;p&gt;•When the above code is compiled and executed, it produces the following result −&lt;br&gt;
   --  Address of var variable: bffd8b3c&lt;br&gt;
   -- Address stored in ip variable: bffd8b3c&lt;br&gt;
   -- Value of *ip variable: 20&lt;/p&gt;

&lt;p&gt;NULL POINTERS&lt;/p&gt;

&lt;p&gt;•It is always a good practice to assign a NULL value to a pointer variable in case you do not have an exact address to be assigned. This is done at the time of variable declaration. A pointer that is assigned NULL is called a null pointer.&lt;/p&gt;

&lt;p&gt;•The NULL pointer is a constant with a value of zero defined in several standard libraries. Consider the following program −&lt;/p&gt;

&lt;p&gt;•EXAMPLE&lt;br&gt;
    #include &lt;br&gt;
    int main () &lt;br&gt;
    {&lt;br&gt;
      int  *ptr = NULL;&lt;br&gt;
      printf("The value of ptr is : %x\n", ptr  );&lt;br&gt;
      return 0;&lt;br&gt;
    }&lt;/p&gt;

&lt;p&gt;•When the above code is compiled and executed, it produces the following result −&lt;/p&gt;

&lt;p&gt;--The value of ptr is 0&lt;/p&gt;

&lt;p&gt;--In most of the operating systems, programs are not permitted &lt;br&gt;
    to access memory at address 0 because that memory is reserved &lt;br&gt;
    by the operating system. &lt;br&gt;
  --However, the memory address 0 has special significance; it &lt;br&gt;
    signals that the pointer is not intended to point to an &lt;br&gt;
    accessible memory location. But by convention, if a pointer &lt;br&gt;
    contains the null (zero) value, it is assumed to point to &lt;br&gt;
    nothing.&lt;br&gt;
  --To check for a null pointer, you can use an 'if' statement as &lt;br&gt;
    follows −&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    if(ptr)     /* succeeds if p is not null */
    if(!ptr)    /* succeeds if p is null */
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

</description>
    </item>
  </channel>
</rss>
