1.fopen--file* fopen (const char* path,const char* mode)
Open Normal file
with buffers
Buffer file system is the use of file structure pointer to manage the file, through the file pointer to the file access, can read and write characters, strings, formatted data, can also read and write binary data
return value: fopen () when the file is successfully opened, returns a pointer to the file that is pointing to the stream, returns null if the open file fails, and the error code exists in errno
2.open--int Open (const char* pathname,int flags)
--int Open (const char* pathname,int flags,mode_t mode)
Open the device file
With no buffers
Non-buffered file system relies on the operating system, through the function of the operating system to read and write files, is the system-level input and output, it does not set the file structure pointer, can only read and write binary files. But high efficiency, fast speed
return Value: Open successfully returns 0, open failed return-1
3.popen--file* popen (const char* command,const char* type)
Open Pipe
return value: Standard I/O stream, must be terminated by Pclose -int pclose (file* stream);
If the call to fork () or pipe () fails, or if memory cannot be allocated, it returns NULL, otherwise the standard I/O stream is returned.
Popen not set errno value for memory allocation failure. If an error occurs when the fork () or pipe () is called, errno is set to the appropriate error type. If the type parameter is not valid, errno will return einval.
The Popen () function creates a child process by creating a pipe, calling fork, and executes a shell to run the command to open a process.
The command parameter is a pointer to a NULL-terminated shell command string. This line of command will be passed to bin/sh and use the-c flag and the shell will execute the command.
The type parameter can only be read or write, and the resulting return value (standard I/O stream) also has a read-only or write-only type corresponding to type. If type is "R" then the file pointer is connected to the standard output of command, and if type is "W" then the file pointer is connected to the standard input of command.
This article is from the "Voice of the Heart" blog, be sure to keep this source http://ljy789.blog.51cto.com/10697684/1764787
fopen, open, Popen