Skip to content

Instantly share code, notes, and snippets.

@res0nat0r
Created July 20, 2010 14:35
Show Gist options
  • Save res0nat0r/483034 to your computer and use it in GitHub Desktop.
Save res0nat0r/483034 to your computer and use it in GitHub Desktop.
fileopentest.c
#include <stdio.h>
#include <stdlib.h>
#define NoOfFILES 16384
int main()
{
char filename[10];
FILE *fds[NoOfFILES];
int i;
for (i = 0; i < NoOfFILES; ++i)
{
sprintf (filename, "/var/tmp/x/%d.log", i);
fds[i] = fopen(filename, "w");
if (fds[i] == NULL)
{
printf("\nNumber of open files = %d. " \
"fopen() failed with error: ", i);
perror("");
exit(1);
}
else
{
fprintf (fds[i], "some string");
}
}
return (0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment