Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Zortech C++ 3.0r4 - <b>write</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
write

Usage

   #include <io.h>
   int write(int fd,void *buffer,size_t length);

Description

   Write length bytes from buffer to the file specified by the file
   descriptor fd. This is a binary-only operation and is not buffered.

Example 

   #include <io.h>
   #include <string.h>
   #include <stdio.h>
   #include <dos.h>
   #include <stdlib.h>

   int main()
   {
       unsigned int fd;
       char *buffer = "Write this data to file";
       unsigned int count;
       int nwritten;
       count = strlen(buffer);
       fd = open("file.dat",O_WRONLY);
       if(fd == -1)
           {
               fputs("Unable to open file",stdout);
               return EXIT_FAILURE;
           }
       nwritten = write(fd,buffer,count);
       printf("\nWRITE:\n%u bytes written to file\n",
               nwritten);
       close(fd);
       return EXIT_SUCCESS;
   }


Return Value

   write returns the number of actual bytes written or a -1 if an error
   occurred and errno is set.





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