Thread: Problem while dealing with file handling functions

  1. #1
    Registered User
    Join Date
    Feb 2006
    Posts
    5

    Problem while dealing with file handling functions

    i wrote a program to copy multiple text files into a single text file. For 13 text files it works fine. But when the number is greater than 13 i.e. iether 14 or more than that the program is not able to open files.( from the 14th file). Do anybody have any idea what is goin on. Is there are some restrictions while opening a massive number of files from a c program.?

  2. #2
    Registered User
    Join Date
    Feb 2006
    Posts
    155
    u forgot fclose.

  3. #3
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    Welcome to the forums!

    There is a limit on the number of files that can open at the same time. This limit is specified by the constant FOPEN_MAX. The C standard guarantees that it will be at least 8, including stdin, stdout and stderr. However, most modern compilers, support a significantly larger number.

    You should attempt to redesign your algorithm to only have a minimum of files open at the same time. From your description of the task, you should only need two files open (one to read from and one to write to).

  4. #4
    Registered User
    Join Date
    Feb 2006
    Posts
    5
    well thnx for you suggestions and advice
    actually i forgot the fclose statement ( before i had written only close)
    now the program is working fine
    i appreciate your help

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Creating File Handling Functions
    By td4nos in forum C Programming
    Replies: 6
    Last Post: 06-26-2009, 11:43 AM
  2. Problem with file handling (pointers)
    By hmk in forum C Programming
    Replies: 5
    Last Post: 09-19-2008, 10:03 AM
  3. Possible circular definition with singleton objects
    By techrolla in forum C++ Programming
    Replies: 3
    Last Post: 12-26-2004, 10:46 AM
  4. File Handling problem
    By skyttkar in forum C++ Programming
    Replies: 1
    Last Post: 07-10-2003, 05:35 AM
  5. what does this mean to you?
    By pkananen in forum C++ Programming
    Replies: 8
    Last Post: 02-04-2002, 03:58 PM