In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces the use of the function rewind in c language, which can be used for reference. Friends who need it can refer to it. I hope you will learn a lot after reading this article. Next, let the editor take you to learn about it.
The function rewind returns the file location pointer to the beginning of the file. The function rewind is to repoint the file pointer to the beginning of a stream. The basic syntax is "void rewind (FILE * stream)".
The function rewind returns the file location pointer to the beginning of the file.
C library function-rewind ()
Function: redirects the location pointer inside the file to the beginning of a stream (data stream / file)
Note: not the file pointer, but the location pointer inside the file, moves backward with the location pointer (pointing to the current read-write byte) of the read and write file to the file. The file pointer points to the entire file, and the file pointer will not change if you do not reassign it.
Usage:
Void rewind (FILE * stream)
Header file: stdio.h
Return value: none
For example: enter a line of characters from the keyboard, append it to a file, and then read out the contents of the file and display it on the screen.
# include int main () {FILE * fp; char ch; if ((fp=fopen ("C:\ Users\\ dell\\ Desktop\ abc.txt", "ab+")) = = NULL) {printf ("\ nCannot open file\ nstrike any key exit\ n"); getchar (); return 1;} printf ("input a string:\ n"); ch=getchar () While (chilled EOF) {fputc (ch,fp); ch=getchar ();} rewind (fp); ch=fgetc (fp); while (chilled EOF) {putchar (ch); ch=fgetc (fp);} fclose (fp); return 0;}
Line 20 of the program, rewind (fp); for each character entered, the file's internal location pointer moves backward one byte. After writing, the pointer has been pointed to the end of the file. If you want to read the file from the beginning, move the pointer to the head of the file and use the rewind () function.
Running result:
Thank you for reading this article carefully. I hope the editor will share the usefulness of the function rewind in c language. At the same time, I also hope that you will support us, pay attention to the industry information channel, and find out if you encounter problems. Detailed solutions are waiting for you to learn!
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.