title: C++ Exception thrown: Access violation writing
body: <blockquote>
    <p>Exception thrown at 0x008F1D0D in whileLTestStr.exe: 0xC0000005: Access violation writing location 0x00770000.</p>
  </blockquote>
  
  <p>This error comes up during runtime when trying to put one character from one array, into another array.</p>
  
  <p>The error occurs right after inputting the string, it does not close the program, just "pauses" it.</p>
  
  <pre><code>#include "stdafx.h"
  #include &lt;iostream&gt;
  #include &lt;cstring&gt;
  
  int main()
  {
      using namespace std;
  
      char test[20];
      char result[20];
      int i = 0;
  
      cout &lt;&lt; "Enter a string without symbolic characters: ";
      cin.get(test, 20);
  
      for (i; (test[i] != '?' || test[i] != '\0'); i++)
      {
          result[i] = test[i];    //Exception gets thrown here
      }
  
      if (strcmp(result, test) != 0)
      {
          cout &lt;&lt; "Fail.";
      }
      else
      {
          cout &lt;&lt; result &lt;&lt; endl;
          cout &lt;&lt; "Success.";
      }
  
      return 0;
  }
  </code></pre>
  
  <p>I've marked out where the exception gets thrown with a comment.</p>
  
  <p>This program is just for limiting what the user can enter, purely for testing. But I don't understand why this doesn't work.</p>
  
  <p>There is probably some function to do this for me, but I'm still learning the language, and I'm just interested in trying and testing what I can do with the loops etc.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>After a suggestion I changed the OR operator for the AND operator, and I no longer get the error. However, I do get some really odd behavior.</p>
  
  <p><a href="https://i.stack.imgur.com/MVody.png" rel="nofollow noreferrer">PICTURE</a> </p>