I have the following code:
#include <stdio.h>
typedef struct {
  int* arg1;
  int  arg2;
} data;
int main(int argc, char** argv) {
  data d;
  printf("arg1: %p | arg2: %d\n", d.arg1, d.arg2);
}
The output ends up being that d.arg1 is not NULL and d.arg2 is 0.  For example:
arg1: 0x7fff84b3d660 | arg2: 0
When I add a pointer to main, nothing changes. However, when I print that pointer:
#include <stdio.h>
typedef struct {
  int* arg1;
  int  arg2;
} data;
int main(int argc, char** argv) {
  data d;
  int* test;
  printf("arg1: %p | arg2: %d | test: %p\n", d.arg1, d.arg2, test);
}
the output always results in:
arg1: (nil) | arg2: 4195264 | test: (nil)
Why am I experiencing this behaviour? I don't understand how printing another pointer value changes the value of a different pointer to NULL. Note that the compiler I am using is GCC 4.8.2.
 
     
     
     
     
    