fopen in C(Linux) returns "Too many open files"

Posted by liv2hak on Stack Overflow See other posts from Stack Overflow or by liv2hak
Published on 2012-06-10T04:36:23Z Indexed on 2012/06/10 4:40 UTC
Read the original article Hit count: 193

Filed under:
|
|
static char filename[128] = "trace.txt";

g_file = fopen(filename, "w");
if(NULL == g_file)
{
       printf("Cannot open file %s.error %s\n",filename,strerror(errno));
       exit(1);
}

I am trying to open a empty text file named trace.txt in write mode (in my working directory.) The program is creating an empty file trace.txt in my directory.but the check (NULL == g_file) is returning true and it is returning error code 24 (Too many open files.).Any idea why this is.This is the first file I am opening in my program.

© Stack Overflow or respective owner

Related posts about c

    Related posts about linux