C pass address of a function return value as function parameter

c, function, memory-address

Solution

A compound literal seems to do the trick (requires a C99 compiler):

int a()
{
    return 5;
}

void b(int *a)
{
    // do something with a
    printf("%d\n", *a);
}

int main(void)
{
    b(&(int){ a() });
}

Output is `5`.

Problem

I have two functions: ``` void a(int * p); int b(); ``` Is it possible to pass the address of the return value of function `b` to function `a` something like this: `a(&b())` ?

Original source