file read

file read

Page 1 of 1

1 Replies - 803 Views - Last Post: 12 October 2008 - 10:38 PM Rate Topic: -----

#1 prads  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 113
  • Joined: 22-October 07

file read

Post icon  Posted 12 October 2008 - 07:05 PM

Hello,
In my C++ code, I am trying to read some values from a huge binary file and perform some computations and then move the file pointer back to a particular location. (Note: the file pointer is not moved back to the beginning) This process is within a loop and hence repeated over time. I have a few questions.
1. Can I move the file pointer by using the following syntax:
 *buffer= *buffer - 100;

2. My requirement is: For the first time within the for() loop, I want to read 500 characters from the beginning of the file. Now the pointer is at the 500th character. Now before the next for() loop begins, the pointer should go back by 100 positions, i.e. to the 400th character and start reading from the 401st character and read upto 900th character (i.e 500 characters from 400th location).
Find the pseudocode below which shows what I am doing. Please guide me because the output is incorrect. I know seekg() does something similar but can you please give me the proper syntax as per my requirement. Actually I want to avoid seekg() because it is computationally expensive (as shown by Profiling) unless there's no way out.
mybin.open ("C:\\file.bin", ios::binary);
mybin.seekg (0, ios::beg);

for (i=0;i<10;1++)
{
char *Buffer=new char[500];
mybin.read (Buffer,500); 

while(condition){
//statement
//statement }

*buffer= *buffer - 100;
}



Thanks,
prads

Is This A Good Question/Topic? 0
  • +

Replies To: file read

#2 prads  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 113
  • Joined: 22-October 07

Re: file read

Posted 12 October 2008 - 10:38 PM

please somebody help me........eagerly waiting
regards,
prads
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1