给文件写数据
#include <io.h>
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
char buffer[] = "look the sample!";
void main( void )
{
int fh;
unsigned byteswritten;
if( (fh = _open( "G:\\write.txt", _O_RDWR | _O_CREAT,
_S_IREAD | _S_IWRITE )) != -1 )
{
if(( byteswritten = _write( fh, buffer, sizeof( buffer ))) == -1 )
perror( "Write failed" );
else
printf( "Wrote %u bytes to file\n", byteswritten );
_close( fh );
}
}