Program gets terminated abruptly in Visual C++
<p>Whwenever I try to execute this block of code it abruptly shuts down if I dont use the <code>getch()</code> function. Moreover I have tried different combinations of accepting and printing the string like <code>gets()</code> and <code>puts()</code> etc. My question is what causes this error and how can i remove this error?</p>

<pre><code>void main()
{
  char str[100];
  printf("Enter your string\n");
  fgets(str,100,stdin);
  printf("%s",str);
  getch();
}
</code></pre>