I'm trying to read hard disk sector to get the raw data. Now after searching a lot I found out that some people are storing that raw sector data in hex and some in char .
Which is better, and why ? Which will give me better performance ?
I'm trying to write it in C++ and OS is windows.
For clarification -
#include <iostream>
#include <windows.h>
#include <winioctl.h>
#include <stdio.h>
void main() {
DWORD nRead;
char buf[512];
HANDLE hDisk = CreateFile("\\\\.\\PhysicalDrive0",
GENERIC_READ, FILE_SHARE_READ,
NULL, OPEN_EXISTING, 0, NULL);
SetFilePointer(hDisk, 0xA00, 0, FILE_BEGIN);
ReadFile(hDisk, buf, 512, &nRead, NULL);
for (int currentpos=0;currentpos < 512;currentpos++) {
std::cout << buf[currentpos];
}
CloseHandle(hDisk);
std::cin.get();
}
Consider the above code written by someone else and not me.
Notice the datatype char buf[512]; . Storing with datatype as char and it hasn't been converted into hex.