title: Writing program in C++ using Microsoft VS, but I get a debug assertion message here. It runs on cpp.sh and repl.it fine, but not on VS. What can I do?
body: <p>This function is meant to remove all special characters, numbers, and whitespace from the char array.</p>
  
  <pre><code>// Michael E. Torres II
  // Vigenere Cipher
  // February 4, 2018
  
  // C++ code to implement Vigenere Cipher
  #include &lt;iostream&gt;
  #include &lt;string&gt;
  #include &lt;iomanip&gt;
  #include &lt;fstream&gt;
  #include &lt;algorithm&gt;
  #include &lt;cctype&gt;
  #include &lt;iterator&gt;
  #include &lt;sstream&gt;
  #include &lt;functional&gt;
  using namespace std;
  
  // This function generates the key in
  // a cyclic manner until it's length isi'nt
  // equal to the length of original text
  string generateKey(string str, string key)
  {
      int x = str.size();
  
      for (int i = 0; ; i++)
      {
          if (x == i)
              i = 0;
          if (key.size() == str.size())
              break;
          key.push_back(key[i]);
      }
      return key;
  }
  
  // This function returns the encrypted text
  // generated with the help of the key
  string cipherText(string str, string key)
  {
      string cipher_text;
  
      for (int i = 0; i &lt; str.size(); i++)
      {
          // converting in range 0-25
          int x = (str[i] + key[i]) % 26;
  
          // convert into alphabets(ASCII)
          x += 'A';
  
          cipher_text.push_back(x);
      }
      return cipher_text;
  }
  
  // This function decrypts the encrypted text
  // and returns the original text
  string originalText(string cipher_text, string key)
  {
      string orig_text;
  
      for (int i = 0; i &lt; cipher_text.size(); i++)
      {
          // converting in range 0-25
          int x = (cipher_text[i] - key[i] + 26) % 26;
  
          // convert into alphabets(ASCII)
          x += 'A';
          orig_text.push_back(x);
          transform(orig_text.begin(), orig_text.end(), orig_text.begin(), ::tolower);
      }
      return orig_text;
  }
  
  string removeNonAlpha(char *str)
  {
      unsigned long i = 0;
      unsigned long j = 0;
      char c;
  
      while ((c = str[i++]) != '\0')
      {
          if (isalpha(c))  // this is where the breakpoint is automatically placed
          {
              str[j++] = c;
          }
      }
      str[j] = '\0';
      return str;
  
  }
  
  // Driver program to test the above function
  int main(int argc, char *argv[])
  {
      string keyword = "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb";
      stringstream ss;
      char a[] = "“I think and think for months and years. Ninety-nine times, the conclusion is false. The hundredth time I am right.” – Albert Einstein “Imagination is more important than knowledge. For knowledge is limited, whereas imagination embraces the entire world, stimulating progress, giving birth to evolution.” – Albert Einstein";
      int i = 0;
  
    string str = removeNonAlpha(a);
  
      str.append(512 - str.length(), 'X');
  
      transform(str.begin(), str.end(), str.begin(), ::toupper);
  
  
      transform(keyword.begin(), keyword.end(), keyword.begin(), ::toupper);
  
  
      string key = generateKey(str, keyword);
      string cipher_text = cipherText(str, key);
  
      transform(cipher_text.begin(), cipher_text.end(), cipher_text.begin(), ::tolower);
      transform(key.begin(), key.end(), key.begin(), ::tolower);
  
      string orig = originalText(cipher_text, key);
  
      cout &lt;&lt; "Original/Decrypted Text : " &lt;&lt; "\n";
  
      for (int i = 0; i &lt; orig.size(); i += 81)
          orig.insert(i, "\n");
      cout &lt;&lt; orig;
  
      cout &lt;&lt; "\n\n" &lt;&lt; "Ciphertext : " &lt;&lt; "\n";
  
      for (int i = 0; i &lt; cipher_text.size(); i += 81)
          cipher_text.insert(i, "\n");
  
      cout &lt;&lt; cipher_text;
  
      cout &lt;&lt; "\n\nPress ENTER key to Continue\n";
      getchar();
  
      return 0;
  }
  </code></pre>
  
  <p>The char array works fine with this while loop, so long as there are no special characters [.,%$@!^]. As soon as there are any special characters in the char array, it gives me the debug assertion: </p>
  
  <p>"Program: ...\Projects\ConsoleApplication17\Debug\ConsoleApplication17.exe
  File: minkernel\crts\ucrt\src\appcrt\convert\isctype.cpp
  Line: 42</p>
  
  <p>Expression: c >= -1 &amp;&amp; c &lt;= 255</p>
  
  <p>...</p>
  
  <p>The program '[11048] ConsoleApplication17.exe' has exited with code 3 (0x3)."</p>
  
  <p>If I run this on repl.it or cpp.sh, I get no issues though. I appreciate any help. Thank you.</p>
  
  <p>It isn't done at all. It needs to be cleaned up a lot, but I'm just trying to test it as is.</p>