You're going about making this program, the wrong way.
What you want to do is start with the essential thing - your struct, and get it set up. Will one struct be enough to hold several members data?
No. So you need an array of these structs. Get that first.
Then start with ONE function, and get it working, then add another function, and get it working, etc.
Big mistake to start on several functions, get a lot of code done, and then find out OOPS! 90% of it is not right, and has to be thrown out, and re-done.
Here's your program with several suggestions in it. No, it does not work, these are suggestions to get rid of obvious errors, only.
Code:
#include <stdio.h>
#include <stdlib.h>
typedef struct
{
char id[5];
char first_name[20];
char surname[20];
int mem_type[5];
int expiry[5];
} DATABASE;
int f_menu (void);
//DATABASE f_add(DATABASE);
void f_add(DATABASE members);
void f_display(DATABASE);
//void main() //int main and with a return, please
int main()
{
DATABASE members;
int menu = 0;
//menu = f_menu (DATABASE);
//DATABASE is an alias for a struct, only.
menu = f_menu();
do
{
switch (menu)
{
case 1 :
f_add (members);
break;
case 2 :
f_display (members);
break;
case 3 :
printf("Exiting Program\n\n");
break;
}
} while (menu != 3);
menu = getchar();
return 0;
}
//int f_menu (DATABASE members) You don't need members in f_menu, at all.
int f_menu()
{
int menu = 0;
printf("\n\nLeisure Center Menu\n");
printf(" 1. Add Members\n 2. Display Members\n 3. Exit\n ");
printf("\nEnter choice: ");
do
{
scanf("%d", &menu);
//fflush(stdin); <==NO!
/* You can't flush your kitchen sink, just your toilet */
if((menu < 1 ) || (menu > menu))
{
printf("Invalid choice. Try again: ");
}
} while ((menu < 1 ) || (menu > menu));
return (menu);
}
//DATABASE f_add(DATABASE)
/*DATABASE is just an alias for a struct name. It's not "something"
to be passed to any function. You want "members", instead.
*/
void f_add(DATABASE members)
{
printf("Enter member ID : ");
gets(members.id);
printf("Enter first name : ");
gets(members.first_name);
printf("Enter surname : ");
gets(members.surname);
printf("Enter membership type : ");
//NOW c'mon! :)
// scanf(members.mem_type);
// fflush(stdin); //quit trying to flush the kitchen sink!
printf("Enter memership expiry month (1-12) : ");
//Again!
// scanf(members.expiry);
// fflush(stdin);
//no return needed
}
void f_display(DATABASE members)
{
}
Why don't you start with adding a very small members[] of say 4, and put in three names, initially. Then in the functions that change the members data, you need to pass the address to the members array.
The above gives no errors, but doesn't work either - it's just a step up.