I have the following code:
int x;
int * xPtr = &x;
int * Get_xPtr(void);
void someFunction(int * y);
int * Get_xPtr(void)
{
return xPtr;
}
void someFunction(int * y)
{
...
...
}
void main(void)
{
someFunction(++Get_xPtr());
}
This code is compiling fine without the increment on the return value (address) of function Get_xPtr(), but with the increment I get the error:
"error: lvalue required as increment operand"
I guess this is not allowed syntax, but why? Is there any other way to do this or do I need to:
int * tempPtr = GetxPtr();
tempPtr++;
someFunction(tempPtr);
someFunction(++Get_xPtr());
++Get_xptr()
requires lvalue to store return value.
simple example will make some clarification
int i=0;
++i; ==>i=i+1; //result stored in i.
variable i can change
++5; //where is lvalue ?
You can use
someFunction(Get_xPtr()+1);