I have the following lines of code :
#define PORT 9987
and
char *ptr = (char *)&PORT;
This seems to work in my server code. But as I wrote it in my client code, it gives this error message :
lvalue required as unary ‘&’ operand
What am I doing wrong?
C preprocessor is at play here. After the code is preprocessed, this how it looks like.
char *ptr = (char *)&9987;
address of (&
) operator can be applied to a variable and not a literal.