Home » Ask & Discuss » Board Exams - CBSE, ICSE, State Boards » Computer Science « Back to Discussion



Computer Science

varsha valli g.'s Avatar
Blazing goIITian

Joined: 31 Jan 2007
Post: 515
29 Mar 2008 20:41:28 IST
0 People liked this
3
644 View Post
file handling!!!!!!!!rates assured!!!!!
None

in certain Q they ask the missing statement:
eg;consider a class book having a func modify()
void modify(book new)
{fstream file;
file .open("book.dat",ios::in|ios::out);
book ob;
int rr=0,f=0;
while(!file)
{file.read(char* &ob,sizeof (ob));
rr++;
if(new.bno()==ob.bno())
{
_______________________
file.write(char* &new,sizeof (new));
f=1}
:
:
:
}
can d missing statement be:   file.seekp(sizeof(ob));
or file.seekp(file.tellg());
plz reply soon
rates assured
!!!!!!!!!!!!!!!!!!!!
 
 


Share this article on:

Comments (3)

sneha.bagri's Avatar

Blazing goIITian

Joined: 5 Jan 2007
Posts: 378
29 Mar 2008 21:50:14 IST
1 people liked this

no it cant b because file.seekp(sizeof(ob)) will take u to d end of d first record and always d second record will get modified


and file.seekp(file.tellg()) will keep u at d place where u are
varsha valli g.'s Avatar

Blazing goIITian

Joined: 31 Jan 2007
Posts: 515
29 Mar 2008 22:44:30 IST
0 people liked this

s thats what i want bcoz when u want to modify a particular record then u have to go to the record by using the bno.
am i right
!!!!!!!!!!!
sneha.bagri's Avatar

Blazing goIITian

Joined: 5 Jan 2007
Posts: 378
29 Mar 2008 22:59:44 IST
1 people liked this

u can use seekp(-sizeof(ob),ios::cur)



Quick Reply


Reply

Some HTML allowed.
Keep your comments above the belt or risk having them deleted.
Signup for a avatar to have your pictures show up by your comment
If Members see a thread that violates the Posting Rules, bring it to the attention of the Moderator Team
Free Sign Up!

Preparing for IIT-JEE ?

Arihant Revision Package for IIT JEE - Books, Practice Tests + Rank Predictor


@ INR 1,995/-

For Quick Info

Name

Mobile No.

Find Posts by Topics

Physics.

Topics

Mathematics.

Chemistry.

Biology

Parents

Board

Fun Zone

Sponsored Ads