#include <stdio.h>
#include <fcntl.h>
#include <sys/stat.h>

main()
{
	int fd;
	FILE *stream;
	fd=open("test.txt",O_CREAT|O_WRONLY,S_IREAD|S_IWRITE);
	stream=fdopen(fd,"w");
	if(stream==NULL)
		printf("fdopen failed\n");
	else
	{
		fprintf(stream, "This is to test fdopen.\n");
		fclose(stream);
	}
	printf("return value=%d\n",close(fd));
	return 0;
}
