title: How to deal with unused array space in C
body: <p>Im working on a Caesar cipher and everything seems to be working fine, except that at the end of my sentences I get a whole bunch of non alpha numerical gibberish added on. Im almost positive this is due to having extra array space, but I need to allow the user to input at 100 characters and C doesn't seem to have an equivalent of an arraylist so I'm not sure how to go about getting rid of this problem.  here is my code </p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;ctype.h&gt;
  
  
  int main ()
   { 
      /* Declare variables to store sentence and shift number. 
         i is used for loops, mod temporarily stores input[i] + shift */
      char input[100];
      int mod;
      int shift;
      int i=0 ;
      printf("sentence "); 
      fgets(input, 100, stdin); //fgets stores user input for sentence
                                //while setting a maximum size
  
      // prompts user to set shift, then mods it to ensure shift stays
      // between 0-26
      printf("\n Number");
      scanf( "%d" , &amp;shift);
      shift = shift % 26;
      //printf( "%d", input[1]);
  
      /* loops. for loop scans through input, and if statements
       * insure input[i] is an alphabet letter and classify
       * it to the letter's respective case. */
      for ( i =0 ; i &lt; 100 ; i++) { 
  
          if ( isupper(input[i])) { 
              mod = input[i] + shift; 
              if (mod &gt; 90) { mod -= 26;}
              if (mod &lt; 65) { mod += 26;}
              printf( "%c", mod );  }
  
          else if( islower(input[i])) {
              mod = input[i] + shift; 
              if (mod &gt; 122) { mod -= 26;}
              if (mod &lt; 97) { mod += 26;}
              printf( "%c", mod );  }
          // my unsuccesful attempt at ignoring empty array spaces
          else if ( input[i] != 000) { 
              printf( "%c", input[i]); 
          }
      }
  
      return 0;
   }
  </code></pre>