Structures on Disk and Contacts List App

computer science

Description

Assignment(#3:(Structures(on(Disk

The(Problem

Your!task!is!to!write!a!program!that!stores!and!retrieves!structures!in!a!file!on!disk.!!The!file!of!

structures!must!remain!on!the!disk!once!your!program!ends.!!You!should!be!able!to!store!

structures to!the!file and!retrieve from!the!file after!restarting!the!program.

The!record!that!you!will!be!writing!to!file!has!the!following!structure:

struct!contact {

!!!unsigned long!phone_number;

!!long first_name_posn;

!!!long last_name_posn;

!!!long company_name_posn;

!!!long email_posn;

!!!long!next;

};

first_name_posn,!last_name_posn,!company_name_posn,!and!email_posn are!the!position in!

the!file of!the!First!Name,!Last!Name,!Company!Name,!and!Email!variable!strings.!!These!

“locations” will!be!required!for!writing and!reading!the!information!to!be stored.

When!you!write!the!structures!on!disk!you!will!need!to!store the First! Name,!Last!Name,!

Company!Name,!and!Email strings!separately!from!the!contact!structure.!!In!the!file!you will!

write!the!contact!structure!first!followed!by!the!First!Name,!Last!Name,!Company!Name,!and!

Email!strings (if!they!exist).!!The!only!required!information!is!the!Phone!Number!– all!other

information!is optional.

The!position!“next” stores!the!location!in!the!file!where!the!next!contact!record!is!stored.

The!file!can!contain!any!number!of!records!and!associated!strings.!!The!name!of!the!file!will!be!

myContactList.db!and!if!the!file!does!not!exist!then!you!program!must!create!it.


Related Questions in computer science category