Pointers For Dummies

wonder

Expert
Licensed User
Longtime User
I know this is a BASIC/Java oriented forum, but just in case someone is struggling with pointers in C, I wrote this for a friend of mine a while ago:

B4X:
#include <stdio.h>

int main()
{
    int intValue = 123645;
  
    int *ptrValue = &intValue;

    printf("The memory address of intValue is   : %X\n", &intValue);
    printf("The memory address of ptrValue is   : %X\n", &ptrValue);
    printf("Content of ptrValue ('points to')   : %X\n",  ptrValue);
    printf("Content of what ptrValue points to  : %d\n", *ptrValue);
    printf("Content of varValue (integer value) : %d\n",  intValue);
  
    return 0;
}

B4X:
The memory address of intValue is   : B1CD0E1C                                                     
The memory address of ptrValue is   : B1CD0E10                                                         
Content of ptrValue ('points to')   : B1CD0E1C                                                          
Content of what ptrValue points to  : 123645                                                           
Content of varValue (integer value) : 123645

Untitled.png


Test it here: https://goo.gl/gyQSkp
 
Last edited:
Top