title: String input with getchar
body: <p>I've a little problem with my code, why when I use printf on string1 (last line), it doesn't give me what I wrote for this variable ?</p>
  
  <p>For example if I wrote : asdfgh, string1 give me something weird like : @>>..</p>
  
  <p>Any idea ?</p>
  
  <p>Thanks for help.</p>
  
  <pre><code> int main()
  {
      int length;
      int i = 0;
      char string1[100];
      printf("Please enter the length of the two strings\n");
      scanf("%d", &amp;length);
  
      printf("\nPlease enter the first string\n");
      while((string1[i] = getchar())!='\n')
          i++ ;
      getchar();
      printf("\nString 1 : %c", string1);
  
      return 0;
  }
  </code></pre>