1 #include <stdio.h>
  2 #include <sys/types.h>
  3 #include <fcntl.h>
  4 #include <stdlib.h>
  5 #include <unistd.h>
  6 
  7 int main(int argc,char *argv[]){
  8 
  9     int fd;
 10     char name[1024];
 11     int i = 0;
 12     while(1){
 13         sprintf(name,"file%d",++i);
 14         fd = open(name,O_CREAT,0777); //超过最大打开数时再打开会出错,返回-1
 15         if (fd == -1){
 16             exit(1);
 17         }
 18         printf("%d ",i);
 19     }
 20     return 0;
 21 }

 

相关文章:

  • 2021-10-06
  • 2022-12-23
  • 2022-12-23
  • 2022-01-01
  • 2021-06-17
  • 2022-12-23
  • 2021-12-03
猜你喜欢
  • 2021-08-03
  • 2022-01-04
  • 2022-03-04
  • 2021-09-11
  • 2022-01-21
  • 2021-08-11
  • 2022-12-23
相关资源
相似解决方案