#include <stdio.h> #include <string.h> struct s { int data; } fun() { static struct s ss; ss.data = 20; return ss; } int main() { struct s ss; memcpy(&ss, &(fun()), sizeof(struct s)); printf("\n Data: :%d", ss.data); return 0; }
In the above program, Im trying to determine the structure in which the return type is specified. struct s is determined successfully.
Is this a legitimate use? I have never seen a real scenario.
How to make this program work?
I get this compiler error:
asd.c: In function 'main': asd.c:21:15: error: lvalue required as unary '&' operand
source share