Dark Horse programmer--c Language learning experience--pointers
-------Java training , Android training ,iOS training ,. Net Training , look forward to communicating with you! -------
1. Open File
fopen (file name, open mode);
For example:
FILE *FP = fopen ("A1", "R"); Returns a pointer to the file (the file's first address in the memory buffer)
The fopen function inverse value is a pointer to a A1 file, usually assigned to a pointer variable
about the file name A1 can also be a "path + file name" C:\abc.txt
--------------------------------------------------------------
Open in the way:
R Read W write a append
r+ w+ A + read-write way to open files
t Open text file
b Open binary file
--------------------------------------------------------------
If open fails, the fopen function returns a null pointer null
if ((Fp=fopen ("File1", "R")) ==null) {
printf ("Open failed! ");
exit (0);
}
2. Close File
close the file with the close function, the general form of the call to the Fclose function is
fclose (file pointer);
For example:
fclose (FP); Fp=0;
Note: If you do not close the file will lose data!!!!
-------Java training , Android training ,iOS training ,. Net Training , look forward to communicating with you! -------
Dark Horse programmer--c Language learning experience--pointers