title: c++ caesar cipher program executes wrong character
body: <p>Here is what I get when I try to encrypt "This is a test sentence!": "Ymnxp���p�����t�������"</p>
  
  <p>I have tested my encryption part before and it worked fine. </p>
  
  <p>Can anyone please tell me what did I do wrong here?</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  #include &lt;fstream&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;stdio.h&gt;
  #include "unistd.h"
  
  using namespace std;
  
  
  void displayUsage(){
      // Displays how to use this program
      // TODO
      cout &lt;&lt; "Instruction: \n use -r to give rotation number \n use -f to give file name" &lt;&lt;endl;
  }
  
  
  int main(int argc, char **argv){
  
    string text;
    char* input_file_name;
    int rotation;
    bool have_rotation = false;
    bool have_input_file_name = false;
  
  
      // process command-line arguement
      int opt = 0;
      extern char *optarg;
      static const char* opt_string = "r:f:";
      opt = getopt( argc, argv, opt_string);
      while(opt != -1) // While there are parameters to parse, do so
      {  
          switch(opt)
          {
              case 'r':
                  have_rotation = true;
                  rotation = atoi(optarg);
                  break;
              case 'f':
                  have_input_file_name = true;
                  input_file_name = optarg;
                  break;
              default:
                displayUsage();
                return 1;
          }
          opt = getopt( argc, argv, opt_string);  // Pull the next parameter, or 0 if none.
      }
  
      if(!have_rotation)
      {
        displayUsage();
        return 0;
      }
  
      if(have_rotation)
      {
        if(have_input_file_name)
        {     
          ifstream file(input_file_name);
          string text2, temp;
          while(!file.eof())
          {
            getline(file, temp);
            text2 += temp;
            text2 += "\n";
          }
          text = text2[text2.size()-2];
        }
        else
        {
        cout &lt;&lt;"Enter text:"&lt;&lt;endl;
        cin &gt;&gt; text;
       }
      }
  
      char cipher[text.size()];
  
      for(int i=0; i&lt;text.size(); i++)
      {
        cipher[i] = text[i];
        if(islower(cipher[i]))
        {
          cipher[i] = (cipher[i] - 'a' + rotation)%26 + 'a';
        }
        else if(isupper(cipher[i]))
        {
          cipher[i] = (cipher[i] - 'A' + rotation)%26 + 'A';
        }
      }
  
      cout &lt;&lt;cipher&lt;&lt;endl;
  
    return 0;
  }
  </code></pre>