title: Reading from stdin using fgets()
body: <p>I'm new to C programming and I'm currently trying to read a line from stdin using fgets(), but I'm having trouble with memory allocation since I'm using a char* to point to the string I want to read. When I execute the file it reports a segmentation fault.</p>
  
  <p>This is the function I'm using:</p>
  
  <pre><code>char *read_line(char *line){
      printf("%s",PROMPT);
      line = (char*)malloc(sizeof(char)*500);
      fgets(line,sizeof(line),stdin);
      printf("%s","pasa el fgets");
      return line;
  }
  </code></pre>
  
  <p>And my main: </p>
  
  <pre><code>void main(){
      char line0;
      char *line=&amp;line0;
      while(read_line(line)){
          execute_line(line);
      }
  }
  </code></pre>