title: Exception thrown at 0x00007FFF168E1657 (vcruntime140d.dll) in "<name>.exe": 0xC0000005: Access violation writing location 0x0000000000000000
body: <p>I tried creating two different visual c++ console applications for Inter Process Communication(IPC). The Build for both codes is successful.But,when I try to debug it, I get exception like this "<strong>Exception thrown at 0x00007FFF168E1657 (vcruntime140d.dll) in FileMapServer_Parent.exe: 0xC0000005: Access violation writing location 0x0000000000000000</strong>" </p>
  
  <pre><code>//PARENT PROCESS:
  
  #include "stdafx.h"
  #include &lt;iostream&gt;
  #include &lt;windows.h&gt;
  #include &lt;Tlhelp32.h&gt;
  #include &lt;stdio.h&gt;
  #include &lt;conio.h&gt;
  #include &lt;string.h&gt;
  #include &lt;cstring&gt;
  #include &lt;cctype&gt;
  #include &lt;fstream&gt;
  using namespace std
  int main()
  {
  cout &lt;&lt; "\t\t.....FILEMAPPING SERVER or PARENT....." &lt;&lt; endl;
  cout &lt;&lt; endl;
  
  //Local Variable Definitions
  
  
      HANDLE  hFileMap;
      BOOL    bResult;
      PCHAR   lpBuffer = NULL;
      char    Buffer[256] = "Hello From File Map Server";
      size_t  szBuffer = size(Buffer);
  
  
  // STEP 1 : Create File Map
  
          hFileMap = CreateFileMapping(
              INVALID_HANDLE_VALUE,
              NULL,
              PAGE_READWRITE,
              0,
              256,
              L"LOCAL\\MyFileMap);
  
  
  if (hFileMap == FALSE)
  {
      cout &lt;&lt; "CreateFileMapping Failed &amp; Error Number - " &lt;&lt; GetLastError() &lt;&lt; endl;
  }
  else
      cout &lt;&lt; "CreateFileMapping Success - " &lt;&lt;  endl;
  
  
  // STEP 2 : Map View of File
  lpBuffer = (PCHAR)MapViewOfFile(
      hFileMap,
      FILE_MAP_ALL_ACCESS,
      0,
      0,
      256);
  
  if (lpBuffer == NULL)
  {
      cout &lt;&lt; "MapViewOf File Failes &amp; Error No - " &lt;&lt; GetLastError() &lt;&lt; endl;
  }
  else
      cout &lt;&lt; "MapViewOf File Success "  &lt;&lt; endl;
  
  
  //STEP 3 : Copy Memory Function
  
  CopyMemory(lpBuffer,Buffer,szBuffer);
  
  
  //STEP 4 : Unmap View Of File
  bResult = UnmapViewOfFile(lpBuffer);
  if (bResult == FALSE)
  {
      cout &lt;&lt; "UnMapViewOfFile Failed &amp; Error No - " &lt;&lt; GetLastError() &lt;&lt; endl;
  }
  else
      cout &lt;&lt; "UnMapViewOfFile FSuccess - " &lt;&lt; endl;
  
  system("PAUSE");
  return 0;
  }
  </code></pre>
  
  <p>Exception while running parent process:
      [1]: <a href="https://i.stack.imgur.com/bomQB.png" rel="nofollow noreferrer">https://i.stack.imgur.com/bomQB.png</a></p>
  
  <pre><code>//CHILD PREOCESS:
  
  #include "stdafx.h"
  #include &lt;iostream&gt;
  #include &lt;windows.h&gt;
  #include &lt;Tlhelp32.h&gt;
  #include &lt;stdio.h&gt;
  #include &lt;conio.h&gt;
  #include &lt;string.h&gt;
  #include &lt;cstring&gt;
  #include &lt;cctype&gt;
  #include &lt;fstream&gt;
  using namespace std;
  
  int main()
  {
  cout &lt;&lt; "\t\t.....FILEMAPPING CLIENT or CHILD....." &lt;&lt; endl;
  cout &lt;&lt; endl;
  
  // Local Variable Definitions
  
  HANDLE  hFileMap;
  BOOL    bResult;
  PCHAR   lpBuffer = NULL;
  
  // STEP 1 : OpenFileMapping
  
  hFileMap = OpenFileMapping(
      FILE_MAP_ALL_ACCESS,
      FALSE,
      L"LOCAL\\MyFileMap");
  if(hFileMap == NULL)
  {
      cout &lt;&lt; "OpenFileMap Failed &amp; error - " &lt;&lt; GetLastError() &lt;&lt; endl;
  }
  else
      cout &lt;&lt; "OpenFileMap success " &lt;&lt; endl;
  
  
  //STEP 2 : MapViewOfFile
  
  lpBuffer = (PCHAR)MapViewOfFile(
      hFileMap,
      FILE_MAP_ALL_ACCESS,
      0,
      0,
      256);
  
      if (lpBuffer == NULL)
      {
          cout &lt;&lt; "MapViewOf File Failes &amp; Error No - " &lt;&lt; GetLastError() &lt;&lt; endl;
      }
      else
          cout &lt;&lt; "MapViewOf File Success " &lt;&lt; endl;
  
  //STEP 3 : Reading the data from File Map Object
  
      cout &lt;&lt; "DATA READING FROM PARENT PROCESS---&gt;" &lt;&lt;lpBuffer&lt;&lt; endl;
  
  //STEP 4 : UnMapViewOfFile
  
      bResult = UnmapViewOfFile(lpBuffer);
      if (bResult == FALSE)
      {
          cout &lt;&lt; "UnMapViewOfFile Failed &amp; Error No - " &lt;&lt; GetLastError() &lt;&lt; endl;
      }
      else
          cout &lt;&lt; "UnMapViewOfFile FSuccess - " &lt;&lt; endl;
  
  //STEP 5 : Close Handle
  
      CloseHandle(hFileMap);
  
  system("PAUSE");
  return 0;
  }
  </code></pre>