title: c++ fgets Segmentation fault (core dumped)
body: <p>The full set of code that encompasses the following snippet compiles with out any error. However when I run the executable I receive an error "Segmentation fault (core dumped)" when line 401 is executed.</p>
  
  <p>I did some debugging and I know that the "real" file name is getting called in line 397 and I have confirmed that "cur_step_buff" is 4096. </p>
  
  <p>Also, please let me know if more code is needed to help with this issue.</p>
  
  <p>Here is the code:</p>
  
  <pre><code>393: FILE *fd;
  394: char fd_name[512];
  395: strcpy(fd_name,npb_list[freq][app][thread].file_name);
  396: fopen( fd_name, "r");
  397: cout &lt;&lt; "fd_name = " &lt;&lt; fd_name &lt;&lt; "\n";
  398: char cur_step_buff[4096];
  399: cout &lt;&lt; sizeof(cur_step_buff) &lt;&lt; "\n";
  400: cout &lt;&lt; “location line 400\n”; 
  401: fgets (cur_step_buff, sizeof cur_step_buff, fd);
  402: int isEnd=0;
  403: int last_step=0;
  </code></pre>