title: fopen get error with char * in c++
body: <p>There is a function to load files:</p>
  
  <pre><code>int loadfile(char *fn)
  {
      printf( "\n my path: '%s' \n", fn );
      FILE *f = fopen( fn, "r");
      printf( "got\n" );
  
      ...
  
      return 1;
  }
  </code></pre>
  
  <p>The first file is in main() <code>newfile( argv[1] );</code>, works. The second is get by flex parsing/reading the first file, what I belive isn't related to the problem. </p>
  
  <p>The console:</p>
  
  <pre><code>path: 'file1.hot' 
  got
  path: 'file2.hot' 
  Segmentation fault: 11
  </code></pre>
  
  <p>The printf was able to print the char *fn, but fopen get a segmentation fault.</p>
  
  <p>The next situation was, I tried explicit to put the file inside the <code>loadfile</code> doing <code>fopen( "file2.hot", "r");</code> and works.</p>
  
  <p>I'm compiling with g++, there is a different approaching when using c++ to use char * or fopen?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Sorry, there's no <code>newfile( argv[1] );</code>. Correct: <code>loadfile( argv[1] );</code>.</p>