title: runtime error (SIGSEGV)
body: <p>can anyone tell me whats wrong in the following program that accepts 1 or 2 digit integers untill it encounters the number 42 after which it prints the previously entered numbers??when i upload this to the sphere online judge site it says  compilation successful but runtime error  (SIGSEGV).</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  int main()
  {
    int i;
    FILE *fp;
    fp=fopen("\\db.txt","w+");
    if(fp==NULL)
    {
     printf("file not exitsts and cant be created");
     system("exit");
    }
    while(1)
    {
     scanf("%d",&amp;i);
     if(i==42)
     break;
     else
     {
      fprintf(fp,"%d\n",i); 
     }    
    }
    fclose(fp);
    fp=fopen("\\db.txt","r+");
    if(fp==NULL)
    {
     printf("file not exitsts and cant be created");
     system("exit");
    }
    fscanf(fp,"%d",&amp;i);
    printf("%d\n",i); 
    while((!feof(fp)))
    {
      fscanf(fp,"%d",&amp;i);
      if(!feof(fp))
      printf("%d\n",i);                
    }
  
    fclose(fp);
    return 0;
  }
  </code></pre>