Originally Posted by
MacGyver
3841925 bytes / 1024 = 3751.8798828125 KB
3751.8798828125 KB / 1024 = 3.66394519805908203125 MB
That seems about right. What are you expecting?
Silly me, i was dividing by 1000 not 1024, so i guess the first part is fine. This is how it looks right now:
Code:
#include <windows.h>
#include <iostream>
int main(int argc, char* argv[])
{
const unsigned int NumberOfOutputFiles = 3;
unsigned long OutputFileSize = 0;
const CHAR *File = "soeasy.mp3";
char *pBuffer = NULL;
HANDLE hFile = CreateFile(File, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
unsigned long TotalFileSize = GetFileSize(hFile, NULL);
std::cout << "File size is: " << TotalFileSize << " bytes." << std::endl;
OutputFileSize = TotalFileSize / NumberOfOutputFiles;
pBuffer = new char[OutputFileSize];
ReadFile(hFile, pBuffer, OutputFileSize, NULL, NULL);
delete[] pBuffer;
return 0;
}
This is giving me segfaults, how come? I can't locate any obvious memory leaks or anything in there?