Professional Documents
Culture Documents
Aim
To create a file and to write contents.
Algorithm
Result
Thus a file has been created with input from the user. The process can be verified by
using cat command.
Program
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
if (argc != 2)
{
printf("Usage: ./a.out <filename>\n");
exit(-1);
}
Output
$ gcc fcreate.c
$ ./a.out hello
File I/O
Open system call is used to either open or create a file.
creat system call is used to create a file. It is seldom used.
^D