title: Dynamically increase and decrease char arrays?
body: <p>I have to send data with UDP. The buffer field is of type char. I also have to encrypt/decrypt what I send. Here's my code for encrypting/decrypting.</p>
  
  <pre><code>const unsigned BUFFER_SIZE = 128;
  char data[BUFFER_SIZE];
  
  cout &lt;&lt; "Enter something." &lt;&lt; endl;
  cin.getline(data, BUFFER_SIZE);
  cout &lt;&lt; data;
  char outchar[BUFFER_SIZE];
  
  
  for(int i = 0; i &lt; strlen(data); i++)
  {
      //outchar[i] = data[i];
              outchar[i] = encr[(int)data[i]];
              cout &lt;&lt; outchar[i];
  
  }
  
  cout &lt;&lt; "Correct so far" &lt;&lt; endl;
  
  
  char transchar[BUFFER_SIZE];
  for(int j = 0; j &lt; strlen(outchar); j++)
  {
  transchar[j] = decr[(int)outchar[j]];
  cout &lt;&lt; transchar[j]; // prints out decrypted text and unused space!
  }
  </code></pre>
  
  <p>The problem here is that using the fixed size of char means there is a lot of unused space in the buffer. In the code provided, it gets printed to screen.</p>
  
  <p>Is there anyway to dynamically increase and decrease the buffer (char array) size so that I do not get the unused space?</p>
  
  <p>EDIT: Something I don't think is clear: <strong>EVERY LETTER has to be encrypted and decrypted!</strong> The words are not encrypted, the letters that make them up are! The advice given up to now would translate words into an array. I need the characters.</p>
  
  <p>EDIT2: deleted.</p>
  
  <p>EDIT3: Russians, you got to love them. Big thanks to Vlad from Moscow!</p>