Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Borland C++ 2.x ( with Turbo C ) - <b>creattemp() create a new file or rewrite an existing one</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 creattemp()             Create a New File or Rewrite an Existing One

 #include   <io.h>

 int        creattemp(filename,attrib);
 char       *filename;                   Name of new file
 int        attrib;                      Attribute word

    creattemp() creates a new file in the directory specified by
    'filename'.  'filename' must be a path name ending with a backslash
    (\), and should allow room to hold a unique file name, which is
    created in the specified directory and stored in 'filename'.  A file
    created with creattemp() is not deleted when the program terminates.

    Like _creat(), creattemp() accepts the MS-DOS attribute word
    'attrib', which must be one of the following constants (defined in
    <dos.h>):

                FA_RDONLY     Read only attribute
                FA_HIDDEN     Hidden file
                FA_SYSTEM     System file


       Returns:     If successful, returns the new file handle, a non-
                    negative integer.  On error, -1 is returned and
                    'errno' (defined in <errno.h>) is set to one of the
                    following:

                    ENOENT         Path or file name not found
                    EMFILE         Too many open files
                    EACCES         Permission denied

   Portability:     MS-DOS 3.0 and later only.

   -------------------------------- Example ---------------------------------

    The following statements create a temporary file in the directory
    '\temp'.

           #include <stdio.h>      /* for printf() */
           #include <dos.h>        /* for _osmajor */
           #include <io.h>         /* for creattemp() */

           main()
           {
               int handle;
               char filename[30];

               if (_osmajor < 3)
                   printf("creattemp() only works for DOS 3.0 or later");
               else {
                   strcpy(filename,"\\temp\\");
                   if ((handle = creattemp(filename,0)) == -1 )
                       printf("couldn't create temp file");
                   else
                       printf("%s created",filename);
               }
           }


See Also: creat() _creat() creatnew()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson