Find the answer to your Linux question:
Results 1 to 3 of 3
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    C Probelm: Max number of times can use fopen in a program


    Im writing a c program and i can only open a file so many times until i get a segmentation fault. I am using fopen and fclose to open and close the files. I believe that the max number of file opens i get is 2040(i close each file after opening the next). Is there any way to increase this number ?



  2. #2
    If you close each file after opening the next then it means that at each
    point you have at most 2 files open.So it doesn't matter how many times
    you call fopen.The problem must be something else.Does your programme
    check the return value of fopen and fclose ?

  3. #3
    I suspect the bug lies elsewhere, and your code is breaking when you've happened to open that number of files. What else is the code doing? Can you reduce to the code to create a minimal failing case and post it here? SEGVs in C programs are usually the result of falling off the end of allocated memory, or misusing/abusing pointers.


  4. $spacer_open

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts