, .
int fseek(FILE *stream, long offset, int whence)
offset - ;
whence ( whence ).
0 . , , . .
:
SEEK_SET ;
SEEK_CUR .
SEEK_END ;
long ftell(FILE *stream)
. -1 errno .
. fsetpos fgetpos.
. xxx.bin.
ß
FILE *in = fopen("c:\\xxx.bin","rb");
if (!in) return;
fseek(in, 0, SEEK_END); //
cout << ftell(in); //
, :
int feof (FILE *stream)
0, , 0 .
, :
int ferror(FILE *stream)
0, .
clearerr, rewind . .
, .
void clearerr(FILE *stream)
void rewind(FILE *stream)
, clearerr, .
errno ( errno.h, stddef.h, stdlib.h) .
.
int fprintf(FILE *stream, const char *format [, argument,...])
[, argument,...] , format. , EOF.
. , . , , . , , .
:
%[][][.][]
|
|
, , , , 8- 16- ;
;
( );
;
.
. 5.
ß
FILE *out = fopen("c:\\xxx.txt","wt");
for (int i = 2; i < 10; i++)
fprintf(out, "%1d x 5 = %2d\n", i, i * 5);
fclose(out);
int fscanf(FILE *stream, const char *format [, address,...])
. EOF.
fscanf . :
( );
, , ;
(n+1)- , n .
, fscanf. , .
(' ',\t,\n), ( , '%') . fscanf , , . fscanf , , .
fscanf , .
:
%[*][][][. .]
* ;
;
N near, F far;
;
, .