Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

structure and array

Status
Not open for further replies.

adrianmah

Computer
Mar 31, 2003
4
0
0
AU
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??
 
Replies continue below

Recommended for you

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!
 
Status
Not open for further replies.
Back
Top