Created
July 20, 2010 14:35
-
-
Save res0nat0r/483034 to your computer and use it in GitHub Desktop.
fileopentest.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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