The Open function opens a few ways to create a file:
1) The first case is by specifying the path:
Open = ("/tmp/text". C ", o_rdwr| O_creat| o_append,0666);
This will automatically create a text.c file in the/tmp file directory.
2) Enter a command in the shell terminal via int mian (int argc,char *argv[]), specify the file, and automatically create the Do not customize the file path by default
Open = (argv[1],o_rdwr| O_creat| o_append,0666);
3) for the file pathname, in fact, the computer is also in the form of strings stored in the system cache, so that we can define a string array to create the file in disguise, but also through the fgets function through the standard input to create open files, but it is important to note that for the standard input, The system will add ' \ n ' at the end of the string to change the file path in the BUF, and we will have to strlen (BUF) in the buf of the fgets input to remove ' \ n '
The specific code is as follows:
How does "UNIX" use BUF and fgets in the Open function in file IO