What's the pointer : Pointer Long « Pointer « C / ANSI-C






What's the pointer


#include <stdio.h>

void main()
{
   long num1 = 0;
   long num2 = 0;
   long *pnum = NULL;

   pnum = &num1;    /* Get num1's address     */
   *pnum = 2;       /* assign 2 to num1       */
   ++num2;          /* Increment num2         */
   num2 += *pnum;   /* Add num1 to num2       */

   pnum = &num2;    /* Get address of num2       */
   ++*pnum;         /* Increment num2 indirectly */

   printf ("\nnum1 = %ld  num2 = %ld  *pnum = %ld  *pnum + num2 = %ld\n",
                                      num1, num2, *pnum, *pnum + num2);
}



           
       








Related examples in the same category