×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

structure and array

structure and array

structure and array

(OP)
i have created 2 array (member and video). both are strcture. i have 3 text file storing the data needed.
(members.txt, videos.txt and loans.txt)
file :
member.txt
12:Ian Richards:Africa:33 Beach Street:Hervey Bay:4655:(07)4567 8901
34:Yan Li:Secret:13 Mockingbird Lane:Mysteryville:7654:(03)2345 6789
56:Fred J. Bloggs:Kidman:45 Blue Gum Parade:Toowoomba:4250:(07)4641 3456

video.txt
123:Armagedon:145
234:2001 A Space Odyssey:156
456:Star Trek Generations:178
567:Apollo 13:135
789:Blade Runner:187
890:Matrix:144

loans.txt
123:12
789:34
890:12


coding:

typedef struct member{
    char id[3];
    char name[20];
    char password[9];
    char address1[20];
    char address2[20];
    char code[5];
    char phone[14];
    char video[3];
} member;


typedef struct video{
    char vcode[4];
    char title[25];
    char runtime[4];
    char memberid[3];
} video;

how can i store all the video that is loan by one same member????
Having 123:12 and 890:12. i am only able to store one video number into member 12. Please help.
How should my member structure be change??

RE: structure and array

One solution is to add another structure used to make the association between a member and a video.

In the loan file, you would have one line per member-video association; there would be no video association in the member structure, nor member association in the video structure.

With this solution, the member file will be changed only when a new member is added, or when a member is removed. The same way, the video file will be changed only when a new file will be added, or when a file will be removed from the inventory.

Hope it helps!

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources