/************************************************************************
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.
****************************************************************************/
}
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.
****************************************************************************/
}
0 comments:
Post a Comment