wtf.c:11:6: error: expected declaration specifiers or '...' before '&' token Swap(&a, &b);
wtf.c:11:10: error: expected declaration specifiers or '...' before '&' token Swap(&a, &b);
Did not want to resort to StackOverflow for my personal problem but i cannot figure it out. The code is exactly the same as the book's. I've also tried making separated pointers and using them as arguments but i get the same error. Can someone shine some light on what am i doing wrong? I'm using gcc to compile the code.
static void Swap(int *x, int *y){
int temp;
temp = *x;
*x = *y;
*y = temp;
}
int a = 1;
int b = 2;
Swap(&a, &b);
I expected it to compile at least the exact example from the book but apparently not even that's possible.