I do not understand C programming pointers very well and I've tried searching the internet looking for information about using simple pointers related to structures. I have this simple program :
#include <stdio.h>
typedef struct
{
int ia;
int ib;
} num;
int main()
{
num *pn;
//int a = 4;
pn->ia = 5;
printf("Hello, I made it this far!\n");
pn->ib = 10;
pn->ia = pn->ib;
printf("num = %d\n", pn->ia);
return 0;
}
This code doesn't work until I uncomment the unused integer 'int a = 4;'
It doesn't seem to matter if I use gcc 32bit or 64 bit on Windows 10.
I want to learn to do this the right way and I don't believe that an unused variable should make it work!