0

I try to point my_next pointer to an integer value like below:

int my_function(int x) {
    return x+1;
}

int *my_next = &my_function(5);

but got the following error:

error: cannot take the address of an rvalue of type 'int'

Any idea what I did wrong and how to fix it? Thanks!

Edamame
  • 23,718
  • 73
  • 186
  • 320
  • So how do I assign my_function output to *my_next? Thanks! – Edamame Jan 31 '19 at 06:42
  • You don't. You've run into a **design** problem, and you're asking for a **code** solution. You need to explain **what** that pointer is used for, and why it needs to point at the value that the function returns. – Pete Becker Jan 31 '19 at 14:00

0 Answers0