FREE TUTORIALS ON C programming

Saturday, January 25, 2014

/************************************************************************

This example creates the file sample.dat so it can be read from and written to.
************************************************************************/


#include <sys\stat.h>


#include <io.h>


#include <stdio.h>


#include <stdlib.h>




int main(void)


{


   int fh;




   fh = creat("sample.txt", _S_IREAD);


   if (-1 == fh) {


      perror("Error in creating sample.txt");


      return EXIT_FAILURE;


   }


   else


      printf("Successfully created sample.txt.\n");


   close(fh);


   return 0;




   /****************************************************************************


      The output should:




       Successfully created sample.dat.


   ****************************************************************************/


}


11:46 PM   Posted by Unknown with No comments

0 comments:

Post a Comment

Bookmark Us

Delicious Digg Facebook Favorites More Stumbleupon Twitter

Search