How can i return a structure, I have tried this:
Code:
#include <stdio.h>
struct list
{
int one, two=0;
};
typedef struct list item;
int main()
{
item thingM;
thingM = funct();
printf("%d\n", thingM.one);
}
item funct()
{
item thing;
thing.one = 10;
return thing;
}
But i get the error message:
Code:
new.c:5: error: expected ‘:’, ‘,’, ‘;’, ‘}’ or ‘__attribute__’ before ‘=’ token
new.c: In function ‘main’:
new.c:12: error: incompatible types in assignment
new.c: At top level:
new.c:16: error: conflicting types for ‘funct’
new.c:12: error: previous implicit declaration of ‘funct’ was here