Page 208 - C++
P. 208
fstream f;
customer c;
f.open (“concat.dat”, ios:: binary | ios :: in | ios :: out );
long cnoc; //customer number whose mobile number needs to be
changed
cin >> cnoc;
while ( f.read((char*) & c, sizeof(c)))
{
if (cnoc == c.getcno( ))
{
c.modify( );
// statement 1
int pos = ________________ // to find the current position
// of file pointer
// statement 2
__________________ // to move the file pointer to write the
// modified record back onto the file
f.write((char *) &c, sizeof(c));
}
}
f.close( );
}
b) Write a function to count and display the number of words which starts with ‘A’
or ‘a’ in the file “data.txt”.
(2)
c) Given a binary file donar.dat, containing records of the following structure type:
(3)
struct donar
{
int dcode;
char dname[20];
char bgroup[3];
};
Write a function in C++ that would read contents from the file “donar.dat” and
creates another file “donar1.dat” copying only those records from donar.dat
where the blood group is either “O” or “A”.
Q5)
a) Define the following terms with the help of an appropriate example.
(2)
i) union ii) DDL
b) Consider the following tables SPORTS and MEMBER and answer (b1) and (b2)
parts of the question:--
Table : SPORTS
SCODE SNAME FEE
S01 BADMINTON 1500
S02 TABLE TENNIS NULL
SO3 BOWLING 7500
Table : MEMBER
MNO NAME DOE DOB GENDER SCODE
501 Girish Vohra 2015-02- 1992-02- MALE S01
01 11
202 Kriti Jha 2010-11- 1991-09- FEMALE S03
10 25
903 Paritosh 2015-06- 1981-10- MALE S02
01 14
107 Ravleen Priya 2009-01- 1981-12- FEMALE S03
17 09
304 Navya Sahni 2011-12- 1996-10- FEMALE S01