I am very new to procedural programming, so I am not sure if my code is bad or if I am doing something wrong in Visual Studio.
So I have this bit of code that is supposed to print an integer, print it's location in memory, change it's value through memory and then print the new integer as well as it's location in memory.
It compiles and runs fine through the cmd with gcc, but not in Visual Studio.
#include <stdio.h>
int main(){
int a = 4;
printf("Integer is: %d\n", a);
printf("Integer is stored at: %p in memory\n", a);
int *pointer = &a;
*pointer = 3;
printf("Integer is now: %d at %p in memory\n",a,*pointer);
getchar();
return 0;
}
Visual studio gives me these errors when I try to compile and run:
line 9: error C2065: 'pointer' : undeclared identifier
line 9: error C2100: illegal indirection
line 11: error C2065: 'pointer' : undeclared identifier
line 11: error C2100: illegal indirection