Files
Linux-C-Notes/C13-IO/stdio/maxfopen.c
2024-05-26 15:39:14 +08:00

32 lines
461 B
C

#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main( )
{
FILE* fp = NULL;
int count = 0;
while (1)
{
fp = fopen("tmp", "w");
if (NULL == fp)
{
perror("fopen()");
break;
}
count++;
}
printf("count = %d\n", count);
// out: 4089
/* 可以通过下面这个命令限制 */
/* ulimit -n */
/* 4096 */
exit(0);
}