title: Why Valgrind cleans my input text file?
body: <p>I got a code that I want to test where do I get a segfault. But when I run valgrind if keeps me turning to a place where I did nothing wrong. It ignores the input txt file and erases it.
  here's the code:</p>
  
  <pre><code>int main(int argc, char * argv[]){
  FILE * input=fopen(argv[1],"r");
  FILE * output=fopen(argv[2],"w");
  int i,j,NumCrom;
  int instancias=0,torres,InstanciaAtual=0;
      fscanf(input,"%i",&amp;instancias);
  //......
  return (EXIT_SUCCESS);
  }
  </code></pre>
  
  <p>valgrind error:</p>
  
  <pre><code> 1 errors in context 1 of 1:
  ==13878== Invalid read of size 4
  ==13878==    at 0x53A935A: __isoc99_fscanf (isoc99_fscanf.c:31)
  ==13878==    by 0x400CF0: main (main.c:18)
  ==13878==  Address 0x0 is not stack'd, malloc'd or (recently) free'd
  </code></pre>
  
  <p>But nothing wrong with that part. It worked to read the txt separately by a function. It cleans the input txt everytime I start the valgrind and that's what returning this segfault (but it got other that doesn't return because the valgrind closes with the first segfault call before that).
  Can anyone help me with that, please?
  And thanks for any help on that.</p>