title: How can I change the size of Array?(and how can I throw the trash values of Array?)
body: <p>Hi I wrote a program below. It's a program, that saves the letters backwards in an Array, when the user gives a string.</p>
  <pre><code>
  int main(){
  
      char string[100];
      char gnirts[100];
  
      int i, j;
  
      printf(&quot;String : &quot;);
      scanf(&quot;%s&quot;, string);
  
      int size = sizeof(string)/sizeof(char);
  
      for(i=size-1, j=0; 0&lt;=i ; i--, j++){
          gnirts[j] = string[i]; 
      }
  
      for(i=0; i&lt;size; i++){
          if(gnirts[i])
              printf(&quot;%c&quot;, gnirts[i]);
      }
  
      return 0;
  }
  </code></pre>
  <p>I gave the program
  <code>String : asdf</code>
  and received
  <code>�i���i���i�fdsa</code></p>
  <p>At the beginning I set the size of <code>string</code> as 100. And then with the line <code>int size = sizeof(string)/sizeof(char);</code> I set Array <code>string</code> with the size, that depends on what the User gives. But it's not working. I got a trash values before the meaningful values.</p>
  <p>How can I delete the trash values and set a new size of the Array <code>string</code> and get the right result?</p>
  <p>Thank you.</p>