HELP... hOW TO Pass value to a struct type and permanently store the data after youve given the data.The programming language is C.
My problem is that as I exit the function "int reg(struct Member listm[], int msize);", the data Ive entered was not stored in the array.
Expand|Select|Wrap|Line Numbers
- #include <stdio.h>
- #include <conio.h>
- #include <string.h>
- struct Member
- {
- char name[50];
- char address[50];
- int age;
- char gender;
- int memID[50];
- };
- struct Video
- {
- char title[50];
- char genre[50];
- int borrow[50];
- int videoID[50];
- };
- int reg(struct Member listm[], int msize);
- main()
- {
- struct Member listm[50];
- struct Video listv[50];
- int choice, again=0;
- int i;
- /*
- for (i=0; i<50; i++)
- {
- listm[i].memID[i]=0;
- listv[i].videoID[i]=0;
- listv[i].borrow[i]='A';
- }*/
- clrscr();
- printf("\nWELCOME TO ANIME VIDEO RENTAL SHOP");
- printf("\nWhat do you want to do?");
- printf("\n1. Register (if not yet a member)");
- scanf("%d", &choice);
- again=reg(listm, 50);
- getch();
- return(0);
- }
- int reg(struct Member listm[], int msize)
- {
- struct Member *mlist[50];
- static int i;
- mlist[50]=&listm[msize];
- printf("\nName: ");
- scanf("%s", &mlist[i]->name);
- fflush(stdin);
- printf("\nAddress: ");
- scanf("%s", &mlist[i]->address);
- fflush(stdin);
- printf("\nAge: ");
- scanf("%d", &mlist[i]->age);
- fflush(stdin);
- i++;
- return(0);
- }