title: How do I write to shared memory in C++?
body: <p>I'd like to write to shared memory and then dump the contents to a file in the win32 api.
  Currently I have this code:</p>
  
  <pre><code>HANDLE hFile, hMapFile;
    LPVOID lpMapAddress;
  
    hFile = CreateFile("input.map",
    GENERIC_READ | GENERIC_WRITE,
    0,
    NULL,
    OPEN_EXISTING,
    FILE_ATTRIBUTE_NORMAL,
    NULL);
  
    hMapFile = CreateFileMapping(hFile,
    NULL,
    PAGE_READWRITE,
    0,
    0,
    TEXT("SharedObject"));
  
    lpMapAddress = MapViewOfFile(hMapFile,
    FILE_MAP_ALL_ACCESS,
    0,
    0,
    0);
  
    sprintf(MapViewOfFile, "&lt;output 1&gt;");
  
    UnmapViewOfFile(lpMapAddress);
    CloseHandle(hFile);
    CloseHandle(hMapFile);
  </code></pre>
  
  <p>However, line 31 (the sprintf call) gives the error:</p>
  
  <pre><code>error: cannot convert `void*(*)(void*, DWORD, DWORD, DWORD, DWORD)' 
  to `char*' for argument `1' to `int sprintf(char*, const char*, ...)'
  </code></pre>
  
  <p>I've tried casting the lpMapAddress to LPTSTR, but it has no effect. What am I doing wrong? Or is there a better way to do it?</p>