title: Mapping files into virtual memory in C on Windows
body: <p>On POSIX systems, I am able to use the mmap function to read the contents of a file faster than getline, getc, etc. This is important in the program that I am developing as it is expected to read very large files into memory; iteratively collecting lines using getline is too costly. Portability is also a requirement of my software, so if I use mmap, I need to find a way to memory map files using the WinApi, as I'd rather not compile through cygwin/msys. From a cursory search I identified <a href="https://docs.microsoft.com/en-us/windows/win32/memory/file-mapping" rel="nofollow noreferrer">this</a> MSDN article which describes very briefly a way to map files into memory, however, from trawling through documentation I can't make head nor tails of how to actually implement it, and I'm stuck on finding example snippets of code, like there are for POSIX mmap.</p>
  <p>How do I use the WinApi's memory mapping options to read a file into a char*?</p>