File programming and time programming:
1. There are two methods for file programming: System Call and c-library function call. The former depends on the linux operating system used, while the latter does not.
2. time Programming is to get the local time and use the time function to get the time!
I. File Creation
Write the following program file_creat.c (using the method called by the System)
1. creat (filename, 0666) creates a file function. filename is the file name, And 0666 indicates the file properties created. The value returned by this function is greater than 0.
2. EXIT_FAILURE = 1; EXIT_SUCCESS = 0
I. File copying (using library functions)
The procedure is as follows:
1. fopen (argv [1], "rb"), where argv [1] indicates the open file name, and "rb" indicates the open method.
2. In the fread (buffer, BUFFER_SIZE, from_fd) function, it indicates that the content in the file to which from_fd points should be read to the buffer cache!
3. fwrite (buffer, file_len, to_fd); the function indicates to write the content of file_len in buffer to the file pointed to by to_fd!
Ii. Time Programming
The Code is as follows: time. c
The above three methods can be converted to local time!
1. The structure of struct tm is as follows:
2. time (NULL) is a function used to obtain the calendar time. Its return value is a time_t type second value.
3. It is a function that converts a calendar time to a local time. The returned value is of the struct tm struct type.
4. The time obtained through the above step is only in the struct, so when we need a more intuitive time display, we need to use the following two functions.