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
/*========================================================== ==========================================Name: quanhaunchong. cAuthor:Version:Copyright: Your copyright noticeDescription: Hello world in C, ANSI-style=====================================
This article mainly introduces the PHP mobile file pointer ftell (), fseek (), rewind () function summary. This article first explains their functions, and then provides specific examples, for more information about how to read and write a file, you
//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
In the process of reading and writing files, it is sometimes necessary to jump in a file, read in different locations, and write data to a different location. For example, you would need to move a file pointer to save data using a file emulation
Question: do not understand ftell () & lt ;? Php $ fp = fopen ('exa', 'r'); $ data = fgets ($ fp, 15); echoftell ($ fp); fclose ($ fp );? & Gt; output in this example: 13 if the value is changed to a relatively large number such as 1046, 13 is also
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)
New question: Do not understand Ftell ()
$fp = fopen (' Exa ', ' R ');
$data = fgets ($fp, 15);
Echo Ftell ($FP);
Fclose ($FP);
?>
Output in this example: 13
If 15 is changed to 1046 of the larger number, also output 13;
If 15 is changed
fopen (Open file)
Defining functions
FILE * fopen(const char * path,const char * mode);
Function description
Parameter The path string contains the file path and filename to open, and the parameter mode
PHP advanced application for PHP file processing allows you to locate and query file pointers, so as to quickly query required information. file pointer functions include rewind (), fseek (), feof () and ftell () functions. In the previous article
fopen (Open file)Correlation function Open,fcloseTable header file #include Defines the function FILE * fopen (const char * path,const char * mode);Function description The path string contains the file path and filename to open, and the parameter
fopen (Open file)Correlation function Open,fcloseTable header file #include Defines the function FILE * fopen (const char * path,const char * mode);Function description The path string contains the file path and filename to open, and the parameter
fopen (Open file)Correlation function Open,fclose
Table header file #include
Defines the function FILE * fopen (const char * path,const char * mode);
The function description parameter path string contains the file path and filename to open, and
Start
# Include
Int fseek (FILE * stream, long offset, int whence );
// The second and third parameters determine the location to be moved. If the operation fails,-1 is returned.// The second parameter is the number of bytes to be moved (moving
Clearerr (error flag for clearing file streams)FeofHeader file # include Define the void clearerr (File * stream) function );Function Description clearerr () clears the error flag used by the file stream specified by the stream parameter.Return
Focus:
Know when to finish reading files: feof () function
Reads one row of data at a time: fgets (), FGETSS (), fgetcsv () functions
Read entire file: ReadFile (), Fpassthru (), file () function
Read one character: Fgetc ()
(1) Rewind () function
This function sets the pointer of the file handle to the beginning of the file stream, with the following syntax:
BOOL Rewind (Resource handle)
(2) fseek () function
The Fseek () function implements the positioning of the
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.