difficulty in reading from dat file and then printing it.

hello everyone, i have got a dat file which is as follows:

é Umair ÌÌÌÌBabar ÌÌÌÌBSCS ÌÌÌÌÌÌÌ×£p=
×@ ê Shahid ÌÌÌFarid ÌÌÌÌBSCS ÌÌÌÌÌÌÌ®Gáz®@ Ž Hassan ÌÌÌKhan ÌÌÌÌBSCS ÌÌÌÌÌÌ̸…ëQ¸ @ î Ahmad ÌÌÌGhazali ÌÌBSCS ÌÌÌÌÌÌÌ @ ¿ Asif ÌÌÌAli ali ÌÌBSSE ÌÌÌÌÌÌ̤p=
×£ @ ð Asim ÌÌÌAli ali ÌÌBSIT ÌÌÌÌÌÌÌ333333
@ Ù Asim ÌÌÌRasool ÌÌMCS ÌÌÌÌÌÌÌ
@ è Ejaz ÌÌÌAshraf ÌÌMCS ÌÌÌÌÌÌÌ)\Âõ(
@ A Tariq ÌÌÌButt f ÌÌBE ÌÌÌÌÌÌÌ…ëQ¸@ ì Hamid ÌÌÌCh. f ÌÌMSc ÌÌÌÌÌÌÌffffff @
ë Syed ÌÌÌUmair ÌÌBSIT ÌÌÌÌÌÌÌÃõ(\Â@ \ Hassan ÌÌÌAli r ÌÌBSIT ÌÌÌÌÌÌÌ×£p=
× @ )# Imran ÌÌÌKhalil ÌÌBSIT ÌÌÌÌÌÌÌ…ëQ¸… @
í Aman ÌÌÌUllah ÌÌBSIT ÌÌÌÌÌÌÌR¸…ëQ
@ G Afnan ÌÌÌAhmad ÌÌBSIT ÌÌÌÌÌÌÌš™™™™™ @ õ Junaid ÌÌÌAhmad ÌÌBSIT ÌÌÌÌÌÌÌHáz®G
@

i have to read the file accordingly in order and then insert it in an index tree in order which we read. my file handling is not that strong and i cannot read it properly. i'll appreciate some help. thankyou!
this is what i have to do:
Each record in the records database is assigned a record number based on that record’s relative position within the database file.
You can use a record number to retrieve an account record directly, much as you can use an array index to reference an array
data item directly. Record numbers are assigned by the database file mechanism and are not part of the account information. As a
result, they are not meaningful to database users. These users require a different record retrieval mechanism, one that is based on
a Student ID (the key for the database) rather than a record number.
//Database file records
struct AccountRecord
{
int recNum; //Record number
int acctID; //Student identifier
char firstName[10]; //First name
char lastName[10]; //Last name
char program[10]; //degree program of a student
double cgpa; //Student’s CGPA
};
The data of the account holder(s) is placed in a binary file named accounts.dat exactly in the format given in the AccountRecord
structure.
Retrievals based on account ID require an index that associates each account ID with the corresponding record number. You can
implement this index using a binary search tree in which each data item contains two fields: an account ID (the key) and a record
number.
Data Structures and Algorithms Home Work 04
Umair Babar, PUCIT – PU. Lahore. Page 2 of 2
struct IndexEntry
{
int acctID; //(Key) Account identifier
long recNum; //Record number
//Return key field
int getKey () const
{
return acctID;
}
};
You build the index by reading through the database account by account, inserting successive (account ID, record number) pairs
into the tree as you progress through the file. The following index tree, for instance, was produced by inserting the account
records shown above into an (initially) empty tree.
Given an account ID, retrieval of the corresponding account record is a two-step process:
1. You retrieve the data item from the index tree that has the specified account ID.
2. Using the record number stored in the index data item, you read the corresponding account record from the database
file.
The result is an efficient retrieval process that is based on account ID.
Create a program that builds an index tree for the accounts database in the file records.dat. Once the index is built, your program
should
 Output the account IDs in ascending order
 Read an account ID from the keyboard and output the corresponding account record.


Topic archived. No new replies allowed.