What is the prototype and definition of a function which returns a structure?
Printable View
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.
Code:typedef struct
{
int a;
} STR;
STR Func()
{
STR str;
str.a = 5;
return(str);
}