How to Pass value to a struct type

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • jadeivel756
    New Member
    • Jul 2007
    • 3

    How to Pass value to a struct type

    I BADLY NEED YOUR HELP......

    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.

    [CODE=c]
    #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("\nWELCO ME 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("\nAddre ss: ");
    scanf("%s", &mlist[i]->address);
    fflush(stdin);

    printf("\nAge: ");
    scanf("%d", &mlist[i]->age);
    fflush(stdin);

    i++;

    return(0);
    }
    [/CODE]
    Last edited by pbmods; Jul 27 '07, 02:27 PM. Reason: Changed CODE language.
  • pbmods
    Recognized Expert Expert
    • Apr 2007
    • 5821

    #2
    Heya, jadeivel756. Welcome to TSDN!

    As this is a C question, and because you have posted an identical thread in the C forum, I will leave a link to your other thread and close this one to keep your responses in one place.

    Comment

    Working...