What is the prototype and definition of a function which returns a structure?
What is the prototype and definition of a function which returns a structure?
Same as any other kind of function which returns a value.
There's no new syntax, so try the obvious thing and see what happens.
Unless you're using some 30-year old fossil compiler, this capability has been officially part of C since 1989.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
Code:typedef struct { int a; } STR; STR Func() { STR str; str.a = 5; return(str); }