title: How do I fix error: Exception thrown at 0x00007FFC284DDDFF (ucrtbased.dll) in EncodeTextApp.exe: 0xC0000005
body: <p>I wrote this code yesterday. It compiles/builds fine with no errors and opens windows command prompt requesting me to input an original text. I input the original text that I want my program to encode and hit enter. This results in the following error:</p>
  <blockquote>
  <p>Exception thrown at 0x00007FFC284DDDFF (ucrtbased.dll) in EncodeTextApp.exe: 0xC0000005: Access violation writing location 0x00007FF7CAEC9C23.</p>
  <p>If there is a handler for this exception, the program may be safely continued.</p>
  </blockquote>
  <p>This exception above happens when I input the <em>message</em> that I want to encode in the command prompt when the program is running. Then it just crashes.</p>
  <p>The code below is the one from my application. I don't know if I'm doing something wrong here.</p>
  <pre><code>#include &lt;stdlib.h&gt;
  #include &lt;conio.h&gt;
  #include &lt;iostream&gt;
  
  #define MAX_LEN 80
  #define encodingshift 17
  
  char* encode(char* str) {
      int i = 0;
      while (str[i] != '\0') {
          str[i] = str[i] - encodingshift;
          /*str[i] = (char)((int)str[i] + encodingshift) % 26;*/
      }
  return (str);
  }
  
  void main() {
      char *str = &quot;&quot;;
  
      printf(&quot;Please enter the message to encode: &quot;);
      fgets(str, MAX_LEN, stdin);
      char* original = str;
  
      str = encode(str);
      printf(&quot;\nOriginal Message: %s&quot;, original);
      printf(&quot;\nEncoding Shift: %d&quot;, encodingshift);
      printf(&quot;\nEncoded message: %s&quot;, str);
      getchar();
  }
  </code></pre>
  <p>I have done everything, from uninstalling the c++ items from Visual Studio and reinstalling them, to installing the whole of Visual Studio again but the error doesn't go away. Therefore, I would like to know what I have to do. It's the only thing stopping me from having my programs work.</p>