Hi, while I was reading the struct tutorial over cprogramming.com, I found this
You can also return structures from functions by defining their return type as a structure type. For instance:
struct database fn();
"Return structures from functions by defining their return type as a structure type"
I tested it by writing a simple program. I am wondering what should I type after return. I tested each of the followings. But doesn't seem to work. Mind to give some help?
My codeCode:return data; return struct data; return data.value;
Code:Code:#include <stdio.h> struct data get_value(void); struct data { int value; float sales; }; int main(void) { getchar(); return 0; } struct data get_value(void) { printf("Enter value : "); scanf("%d", &data.value); printf("\nEnter sales : "); scanf("%f", &data.sales); return data.value; // <--- This one }