Click here to Skip to main content
15,614,147 members
Please Sign up or sign in to vote.
3.50/5 (2 votes)
See more:
Hi please guide me!
I work with C++ but I'm beginner ...
I think for one file on the hard disk we have many part in memory and many address for each block(part).
For example if we have a file with 64kb size ... that use 16 block(4kb) or 2block(32kb).
If I'm not in mistake so we have some memory address for each part of file.
Now I want to find these address with C++ codes ... when I know name and place of file in hard drive.
(for example I have this adress: D:/new folder/memory.doc ... and I want memory adress for each part of file's data.)
I hope you can understand my problem/question and I could explain my problem ...!
please explain your way because I'm beginner ....

Thanks in advance!
Posted
Comments
[no name] 17-Mar-11 8:03am    
Could you show the code which reads a file to memory? That decides which memory address it goes to.

1 solution

No, disk files are not broken into blocks that you need to be concerned about.
You can have an offset within the file, which you can use via Streams but that is about it.

If this is a particular data file type, then it may be logically organised into internal blocks, but that is totally at the whim of the file format designer.


More complex explanation:
Files are physically broken into blocks both logical (OS controlled) and physical (HDD controlled) but since most HDD's lie about the internal platter count, head count, and frequently physical size of a sector, and the OS block size has no relation to this anyway, it is not something most programmers need to think about, much less program for. Remember that the OS will cache HDD data, and will often access it via the VM page system anyway as needed as well as the HDD having it's own internal cache. Real block size is immaterial and any attempt to refer to it will often cause more trouble and slow down than it is worth.
 
Share this answer
 
Comments
Olivier Levrey 17-Mar-11 8:22am    
Very good explanations. Have my 5+.
Sergey Alexandrovich Kryukov 17-Mar-11 16:17pm    
Excellent explanation, a 5, and an interesting example of of novice thinking: the level of achievements in the industry is highly underestimated (as if systems was created by morons :-), and the complexity of simple things exaggerated...
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900