title: Unhandled exception at 0x0FA6F6E0 (ucrtbased.dll). A read access violation at 0x00000000 has occurred
body: <p>This is my C++ code to data encryption. The code runs, but does not work correctly! I don't know what is wrong
  The debugger shows this error:</p>
  <pre><code>An unhandled exception at 0x0FA6F6E0 (ucrtbased.dll) in ConsoleApplication6.exe:
  0xC0000005: A read access violation at 0x00000000 has occurred
  </code></pre>
  <p>Here is my code:</p>
  <pre><code>#include&lt;iostream&gt;
  #include&lt;conio.h&gt;
  #include&lt;fstream&gt;
  #include&lt;string.h&gt;
  #include&lt;stdlib.h&gt;
  #include&lt;math.h&gt;
  using namespace std;
  void main(int argc, char **kluch)
  {
      system(&quot;cls&quot;);
      cout &lt;&lt; &quot;Key: N+3&quot; &lt;&lt; kluch[1];
      ifstream in(&quot;C:\\Users\\s1mi\\source\\repos\\ConsoleApplication6\ConsoleApplication6\123\Input.txt&quot;);
      ofstream out(&quot;C:\\Users\\s1mi\\source\\repos\\ConsoleApplication6\ConsoleApplication6\123\Output.txt&quot;);
      if (!in)
      {
          cout &lt;&lt; &quot;\nThere is no filefor coding (Input.txt).&quot;;
          cout &lt;&lt; &quot;\n\nPres any key for exit.&quot;;
          _getch();
          exit(1);
      }
      char temp, buf = NULL;
  
      int n = strlen(kluch[1]);
      int j, i = 0;
      for (int k = 0; k &lt; n; k++)
          while (!in.eof())
          {
              in.read((char*)&amp;buf, sizeof(buf));
              if (buf == NULL)break;
              j = fmod(i, n);
              temp = buf ^ kluch[1][j];
              out.put(temp);
              i++;
              buf = NULL;
          }
      in.close();
      out.close();
      cout &lt;&lt; &quot;\nThe text is in a file Output.txt&quot;;
      _getch();
  }
  </code></pre>