title: Encryption and decryption with ASCII in C++
body: <p>As I am new to coding c++ and am taking a object oriented class, I need some help. For this code I want to encrypt it by shifting all of the text that is enter by 1 ascii digit i.e. a -> b, b-> etc. I am suppose to use all ascii values 32 - 126 but I cant figure out why when i try to encrypt anything I only get a "^" as a output.</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  using namespace std;
  
  void encrypt (string &amp;encrypt)
  {
      string encryption;
  
      for (int i = 0; i &lt; encrypt.length(); i++)
      {
          encrypt[i]++;
          if (i &gt; 126){
              encrypt  = i - 94;
          }
          else if (i &lt; 32){
              encrypt = i + 94;
         }
      }
  }
  
  void decrypt (string decrypt)
  {
      string decryption;
  
      for ( int i = 0; i &lt; decryption.length(); i ++)
      {
          decryption[i]--;
          if (i &gt; 126){
              decrypt  = i + 94;
          }
          else if (i &lt; 32){
              decrypt = i - 94;
          }
      }
  }
  
  int main ()
  {
      string option;
      string encryption1;
      string decryption1;
      cout &lt;&lt; "Do you want to encrypt or decrypt? \n";
      cin &gt;&gt;  option;
  
      if (option == "encrypt")
      {
          cout &lt;&lt; "What do you want to encrypt \n";
          cin.ignore();
          cin.clear();
  
          getline (cin, encryption1);
          encrypt ( encryption1);
          cout &lt;&lt; encryption1 &lt;&lt; " " &lt;&lt; endl;
      }
  
      if (option == "decrypt")
      {
          cout &lt;&lt; "What do you want to decrypt \n";
          cin.ignore();
          cin.clear();
  
          getline (cin, decryption1);
          encrypt ( decryption1);
          cout &lt;&lt; decryption1 &lt;&lt; " " &lt;&lt; endl;
      }
      return 0;**
  </code></pre>