title: Access Violation C++
body: <p>I am new to c++, and I'm facing the Access Violation exception.
  The problem is as follows, I have backend.h file which contains the struct</p>
  
  <pre><code>struct Config
  {
   ....
  }conf;
  get_conf();
  </code></pre>
  
  <p>The implementation in backend.cpp</p>
  
  <pre><code>Config get_conf()
  {
  return conf;
  }
  </code></pre>
  
  <p>backend.cpp and backend.h are compiled and built to generate a dll.
  This dll is included in a VS solution that way</p>
  
  <pre><code>Config config = get_config();
  Config *g_config = &amp;config;
  </code></pre>
  
  <p>The code compiles and run fine but it throws an exception when the function is called</p>
  
  <pre><code>First-chance exception at 0x75d6d36f in BA.exe: Microsoft C++ exception: std::bad_alloc at memory location 0x002ec494..
  First-chance exception at 0x75d6d36f in BA.exe: Microsoft C++ exception: std::bad_alloc at memory location 0x002ebe28..
  First-chance exception at 0x75d6d36f in BA.exe: Microsoft C++ exception: [rethrow] at memory location 0x00000000..
  First-chance exception at 0x77962d37 in BA.exe: 0xC0000005: Access violation reading location 0x41ce5ab2.
  Unhandled exception at 0x77962d37 in BA.exe: 0xC0000005: Access violation reading location 0x41ce5ab2.
  The program '[4624] BA.exe: Native' has exited with code -1073741819 (0xc0000005).
  </code></pre>
  
  <p>I think the problem has something to do with pointers &amp; struct please help me out</p>