title: Using fgets() with char* type
body: <p>I have a simple question about using fgets() with char* string.</p>
  
  <pre><code>....
  char *temp;
  FILE fp=fopen("test.txt", "r");
  
  fgets(temp, 500, fp);
  printf("%s", temp);
  ....
  </code></pre>
  
  <p>This code didn't work well.</p>
  
  <p>But after I modified <code>char *temp</code> to <code>char temp[100];</code>, the code worked well as I intended.</p>
  
  <p>What is the difference between those two?</p>
  
  <p>When I googled it, some said that memory must be allocated to <code>char *</code> using malloc()...</p>
  
  <p>But I couldn't understand it.</p>