home *** CD-ROM | disk | FTP | other *** search
/ Super PC 34 / Super PC 34 (Shareware).iso / spc / UTIL / DJGPP2 / V2 / DJTST200.ZIP / tests / libc / posix / sys / stat / stat1.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-04-18  |  633 b   |  39 lines

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <unistd.h>
  4. #include <fcntl.h>
  5.  
  6. int
  7. main (int argc, char *argv[])
  8. {
  9.   int i, n, last_fd;
  10.   
  11.   if (argc != 2)
  12.     {
  13.       fprintf (stderr, "Usage: %s #files\n", argv[0]);
  14.       exit (-1);
  15.     }
  16.  
  17.   n = atoi (argv[1]);
  18.  
  19.   last_fd = -1;
  20.   for (i = 0; i < n; i++)
  21.     {
  22.       char name[256];
  23.       int fd;
  24.  
  25.       sprintf (name, "/tmp/foo%d", i);
  26.       if ((fd = open (name, O_CREAT, 0777)) < 0)
  27.     {
  28.       fprintf (stderr, "open number %d failed, last fd = %d.\n", i,
  29.            last_fd);
  30.       perror ("");
  31.       exit (-2);
  32.     }
  33.       last_fd = fd;
  34.     }
  35.  
  36.   return 0;
  37. }
  38.  
  39.