The value you are printing out is the address of the buffer, rather than its contents. And the address of the buffer is not fixed. Of course, arguing about why the address of the buffer can change is a little moot since you actually want to print out the buffer’s contents.
Print out the first element of the array like this:
cout<<"\n\n"<<buff[0]<<"\n\n";
And you should see values read from the disk.
Some other comments:
- Don’t hard code the buffer size. You have to ensure that it is a multiple of the sector size.
- Your buffer should be of type
unsigned char*
rather thanunsigned int*
. - Check the value
nRead
in case the buffer is only partially filled.
9
solved Moving the file pointer of a disk with SetFilePointerEx [closed]