main()
{
	int fd;		/* file descriptor */

	/*
	 * First try to open the file.  If we
	 * can't, then try to create it with mode
	 * 0644 (\-rw\-r\-\-r\-\-).  Note the 0 in front
	 * of 644 to specify octal.
	 */
	if ((fd = open("foo", 1)) < 0) {
		if ((fd = creat("foo", 0644)) < 0) {
			printf("Cannot create foo.\en");
			exit(1);
		}
	}

	/*
	 * Now close the file.
	 */
	close(fd);
}
