Due to server problems the website is temporarily offline! Visit http://www.smorgasbordet.com/pellesc/ to download Pelles C.
#include <stdio.h>int x = 12;int *p;p = &x;int main(void){ printf("%d\n", *p); return 0;}
Why doesn't this run?Code: [Select]#include <stdio.h>int x = 12;int *p;p = &x;int main(void){ printf("%d\n", *p); return 0;}According to K&R it's valid C.
Great, thanks.Can you please explain why it needs to be in a function? Is it because you can only do initializations outside?
#include <stdio.h>int x = 12; // create int with content 12int *p = &x; // create pointer with content address of int xint main(void){ printf("%d\n", *p); return 0;}