title: Unknown characters being displayed while printing character array
body: <p>I'm creating a Caesar cipher in C and I'm having an issue when displaying the encoded message. It works if the message consists of very few characters but as soon as the message exceeds a certain amount of characters the <strong>printf</strong> function begins to display unknown characters which I assume are junk bytes. Any ideas?</p>
  
  <p>Code: </p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;string.h&gt;
  
  char *concat(const char *s1, const char *s2)
  {
      /*
          Remember to free allocated memory
      */
      char *result;
      if((result = malloc(strlen(s1)+strlen(s2)+1)) != NULL)
      {
          result[0] = '\0';
          strcat(result, s1);
          strcat(result, s2);
      }
  
      return result;
  }
  
  void encode(const char *alpha, const char *message)
  {
      char result[(sizeof(message) / sizeof(char))];
      int x, y, z;
  
      memset(result, '\0', sizeof(result));
      for(x = 0; x &lt; strlen(message); x++)
      {
          for(y = 0; y &lt; 25; y++)
          {
              if(alpha[y] == message[x])
              {
                  z = (y + 3);
                  if(z &gt; 25)
                  {
                      z = z % 25;
                  }
  
                  result[x] = alpha[z];
              }
          }
      }
  
      printf("%s\n", result);
  
      //return result;
  }
  
  int main()
  {
      char message[200];
      char *result;
      char array[26] = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' };
  
      printf("Input your message:");
      scanf("%s", &amp;message);
  
      encode(array, message);
  }
  </code></pre>
  
  <p>Result:</p>
  
  <p><a href="https://i.stack.imgur.com/IAIel.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IAIel.png" alt="enter image description here"></a></p>