In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-11 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
Editor to share with you how to use gets and puts in linux to read and write files. I hope you will get something after reading this article. Let's discuss it together.
# include # define MAXLINE 4096 / / defines the maximum length of a line of characters int main (int argc,char * argv []) {char buf [MAXLINE]; / / read / write buffer int len; / / length counter of the write buffer int I = 0; FILE * fp; / / file structure pointer char writebuf [] = "hellographi have read this file.\ n" / / write buffer if (argc! = 2) {printf ("Please enter the correct parameter / n"); / / Parameter error return 1;} fp = fopen (* (argv+1), "ab+"); / / Open specified stable if (fp = = NULL) {printf ("Open file% s failed!\ n", * (argv+1)); return 2 } / / read data from the file until it reaches the last bit of the file while ((fgets (buf,MAXLINE,fp))! = NULL) / / if it does not reach the last bit of the file {fputs (buf,stdout); / / outputs characters} fputs (writebuf,fp) in standard output; / / writes the data written to the buffer to the file fclose (fp) / / turn off counter return 0;} after reading this article, I believe you have some understanding of "how to use gets and puts to read and write documents in linux". If you want to know more about it, please 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: 0
*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.