There is nothing wrong here with pointer or dereferencing operator (*
). It seems that you are not compiling your code in C99 mode. In C89 mixed type declarations are not allowed.
EDIT: As OP said in his comment that he is using MS Visual Studio 2012, MSVC does't support C99 (basically it is a C++ compiler). You can't compile your code in C99 mode. Now declare all the variables in the beginning of the code like C89;
int y=4;
int *addressOfVariable=&y;
int memoryValue=*addressOfVariable;
....