PHP File processing advanced application-file pointer php can implement the positioning of the file pointer and query, so as to achieve the required information fast query, the file pointer function has rewind (), fseek (), feof () and Ftell ()
/*========================================================== ==========================================Name: quanhaunchong. cAuthor:Version:Copyright: Your copyright noticeDescription: Hello world in C, ANSI-style=====================================
//file function re-speak//fseek (), Ftell (),#define_crt_secure_no_warnings#include#includevoidMain () {//Defining file Paths Char*path ="E:\\look\\b1.txt";//Support window only Char*path1 ="E:/look/b1.txt";//support Windows and
Requirement: when reading a file, you need to know the total number of characters in the file, which may be to define the buffer size or copy the file in advance. It can also be used to dynamically create arrays.
Before proceeding to these two
1. fopen
FILE * fopen (const char * path,const char * mode); function Description
The parameter path string contains the file path and filename you want to open, and the parameter mode string represents the flow pattern.
Mode has the following
C-language Lseek () function: Moving a file's read/write location
Header file:
#include #include
To define a function:
off_t lseek (int fildes, off_t offset, int whence);
Function Description:Each open file has a
Http://blog.sina.com.cn/s/blog_61437b3b0102v0bt.htmlhttp://blog.csdn.net/chenwk891/article/details/8776479 in c\c++, the file operations are implemented by the library function, mainly divided into two types of read and write operations, the
reprinted from: http://blog.csdn.net/xidianzhimeng/article/details/235412891 fopenFunction prototype: File * fopen (const char * path,const char * mode); return value: When the file is opened successfully, the pointer to the stream will be returned.
fseek function:
int fseek (FILE * _file, long _offset, int _origin);
function to set the location of the file pointer stream. If the execution succeeds, the stream points to the position of Fromwhere as the offset (pointer offset)
fopen
Function prototype FILE * fopen (const char *path,cost char *mode)
Action: Opens a file that returns a pointer to the file
Parameter description: The first parameter is the file path and file name to open the file, and the second parameter
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.