: ; ; ; ; ; .
1. .
2. .
3. .
7. -
,
, - . :
- , - [1, 3];
- ;
- ;
- .
-
() -. - . - , stdio.h. - , . , .
, . -.
(stream) , - . (), - (, , , .), . , , .. - .
- :
:
- ;
- ;
- .
:
- ;
- .
- , - , ( ), . , ( ). , , , . - 8.
|
|
8 -
-
, . FILE.
:
FILE * fopen(const char *name, const char * mode);
: name , , mode , , mode 2- , 1- , :
r , ;
w , , ; a , , , , , ;
r+ + , ( );
w+ + , , ( );
a+ + , .
, :
t ( ), \r\n \n, , , 1A ;
b , .
FILE NULL .
:
FILE *pF;
pF=fopen(MyFile.txt, w);
MyFile.txt, . , .
FILE *pF;
pF=fopen(C:\\Catalog1\\MyFile.dat, rb);
MyFile.dat : Catalog1, , , NULL. , \ , , \.
FILE *pF;
pF=fopen(C:\\Catalog1\\MyFile.txt, a+);
MyFile.txt : Catalog1, , , , .
, Microsoft Visual ++ 2013 fopen ( ), , fopen fopen_s. :
errno_t fopen_s(
FILE** pFile,
const char *filename,
const char *mode
);
, FILE . :
|
|
FILE *pF;
fopen_s(&pF, MyFile.txt, w);
, , , . , , , .
:
int fclose(FILE * stream);
stream FILE, , 0, EOF .
, . , 0, , .
, , :
int feof(FILE * stream);
stream FILE, , 0, 0, .
, stdout. , stream FILE, . .
:
int fputc(int c, FILE *stream);
:
int fputs(const char * s, FILE * stream);
( ):
int fprintf(FILE * stream, const char * format, );
, , , .
:
unsigned fwrite(void * buf, unsigned size, unsigned count, FILE *stream);
: buf , , size , count ( ), stream FILE; .
, stdin. , stream FILE, . .
:
int fgetc(FILE * stream);
:
char * fgets(char * s, int n, FILE * stream);
n .
:
int fscanf(FILE * stream, const char * format, );
, .
:
unsigned fread(void *buf, unsigned size, unsigned count, FILE *stream);
: buf , , size , count ( ), stream FILE; .