In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-08 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
What is the fopen function of Linux? I believe many inexperienced people don't know what to do about it. Therefore, this paper summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.
Fopen (Open File)
Correlation function open,fclose
Header file # include
Define the function FILE * fopen (const char * path,const char * mode)
The function description parameter path string contains the file path and file name to be opened, while the parameter mode string represents the flow pattern.
Mode has the following morphological strings:
R Open a read-only file, which must exist.
R + Open a read / write file, which must exist.
W Open a write-only file. If the file exists, the length of the file is cleared to 0, that is, the content of the file will be deleted.
Lose. Create a file if it does not exist.
W + opens the read-write file. If the file exists, the length of the file is zero, that is, the contents of the file.
Will disappear. Create a file if it does not exist.
An opens the write-only file in an additional way. If the file does not exist, the file will be created
If the file exists, the written data will be added to the end of the file, that is, the original contents of the file will
To be retained.
A + opens a read-write file in an additional way. If the file does not exist, the text will be created
If the file exists, the written data will be added to the end of the file, that is, the original
The content will be retained.
All of the above morphological strings can be added with a b character, such as rb, Whiteb, or ab+
The b character is added to tell the function library that the open file is binary rather than pure
Text files. However, on POSIX systems, including Linux ignores this character. By fopen
() the new document created will have
S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH (0666) permission. The umask value is also used for this file permission.
After the return value file is successfully opened, the file pointer to the stream is returned. If the file fails to open, return NULL and store the error code in errno.
Generally speaking, some file reading or writing actions will be made after opening the file, and if the open file fails, the following read and write action can not be carried out smoothly, so please make an error judgment and handling after fopen ().
After reading the above, have you mastered what the fopen function of Linux is? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 296
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.