title: Printing character array error in C
body: <p>While trying this code in C, I'm seeing garbage value in main method. What mistake I'm doing?</p>
  
  <p>I hope that I should use "%s" in main method also but seems like wrong. Why?</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  char* minimumMultiple(int num);
  
  int main(void) {
  // your code goes here
  printf("%s", minimumMultiple(13)); // prints  -  *p·ä…d¿“¿Eƒ (GARBAGE) - WHY?
  return 0;
  }
  
  char* minimumMultiple(int num) {
  int chars1s = 1, rem = 1;
  while (rem != 0) {
      rem = (rem*10+1) % num;
      chars1s++;
  }
  char chars[chars1s];
  int i;
  printf("%d\n", chars1s); // prints 6 
  for (i=0;i&lt;chars1s;i++) {
      chars[i] = '1';
  }
  chars[i] = '\0';
      printf("%s\n",chars); // prints "111111"
  return chars;
  }
  </code></pre>