ccoolgoose's Avatar, Join Date: Jun 2009
Light Poster
Not a problem..I mean...not consecutive blocks...but want to write/read the whole file. not 1,2,3...something like...1,50,2000, etc....till 1 GB
SaswatPadhi's Avatar, Join Date: May 2009
~ Б0ЯИ Τ0 С0δЭ ~
Did you see my last post ?
You can use the func SeekTo_NthBlock to write to any block at any time.

Code: C
// Writing randomly
short IsWritten[10485];
memset(IsWritten, 0, 10485*sizeof(short));
int TotalWritten = 0;
int WriteToBlock;

while (TotalWritten < 10485 )
{
      WriteToBlock = rand() % 10485;
      if ( IsWritten[WriteToBlock] )      continue;
      SeekTo_NthBlock(fp, WriteToBlock, 102400);
      fwrite(buff, 1, 102400, fp);
      IsWritten[WriteToBlock] = 1;
      ++TotalWritten;
}

Is it okay now ?
ccoolgoose's Avatar, Join Date: Jun 2009
Light Poster
Random ...i meant not sequential...but i wanted to write all 10485 blocks. how do i make sure i have written all the blocks
SaswatPadhi's Avatar, Join Date: May 2009
~ Б0ЯИ Τ0 С0δЭ ~
Quote:
Originally Posted by ccoolgoose View Post
How do i make sure i have written all the blocks
I guess you are able to read the post just above yours.
What does while(TotalWritten < 10485) mean ??
ccoolgoose's Avatar, Join Date: Jun 2009
Light Poster
I was trying to post...but I don't know it doesn't allow me
ccoolgoose's Avatar, Join Date: Jun 2009
Light Poster
Sorry...somehow I couldn't see your posts. Thank you very much!
SaswatPadhi's Avatar, Join Date: May 2009
~ Б0ЯИ Τ0 С0δЭ ~
You are welcome !