I have a small file, I go over it and count the number of bytes in it:
while(fgetc(myFilePtr) != EOF)
{
numbdrOfBytes++;
}
Now I allocate virtual memory of the same size:
BYTE* myBuf = (BYTE*)VirtualAlloc(NULL, numbdrOfBytes, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
I now want to copy the content of my file into nyBuf. How do I do it?
Thanks!
mmap
that will do this for you without having to specifically allocate memory. It's possible Windows has something similar. – Gavfseek(fp, 0L, SEEK_END); long size = ftell(fp); rewind(fp);
– Kiowa