????1. ???????????????????(????)
????linux?ж??????豸?????????????????????????????????????????????????豸?????
????1.1. ????????????????
??????????
????#include <stdio.h> //????????
????FILE *fopen(const char *pach??const char *mode); //????? ??
????int fclose(FILE *stream);
????fopen??mode?????????????????????????????????????????????NULL.
????fopen????????????????????0666?????umask??????????
????1.2. ??д???
????????????????????д?????????????????飺
??????????д??
????#include <stdio.h>
????size_t fread(void *ptr?? size_t size?? size_t nmemb?? FILE *stream);
????size_t fwrite(void *ptr?? size_t size?? size_t nmemb?? FILE *stream);
????fread???????stream ?ж??nmemb??????д??ptr????????У?????????С?size??????
????fwrite??ptr????????ж??nmemb??????д???????stream?У???????size??????
???????е??????д?????????????????д?????д????д??????????д????????????size*nmemb??????
????1.3.?????λ??
?????????λ??????????????????д?????е???????????д????????????????????????д???д??????
?????????????У?
????#include <stdio.h>
????int feof(FILE * stream); //??????÷??while(!feof(fp))
????int fseek(FILE *stream?? long offset?? int whence);//????????д?????whence ?????offset??
????long ftell(FILE *stream); //??????????????????дλ??
????void rewind(FILE *stream); //??????????дλ???????????? èfseek(fp?? 0?? SEEK_SET);
????feof?ж??????????β??????????????????β?????????Σ?
????fseek????????д?????whence ?????offset????whence???????
????SEEK_SET (?????? –>0)
????SEEK_CUR (??????λ?? –>1)
????SEEK_END (????β –>2)
????ftell?????????д??
????rewind??????????д???????????
????1.4.???????д??
????#include <stdio.h>
????int printf(const char *format?? ...); //????fprintf(stdout??format??…);
????int scanf(const char *format?? …);
????int fprintf(FILE *stream?? const char *format?? ...);
????int fscanf(FILE *stream?? const char *format?? …);
????int sprintf(char *str?? const char *format?? ...); // eg: sprintf(buf??”the string is;%s”??str);
????int sscanf(char *str?? const char *format?? …);
??????f???????????????????д???????stream??
??????s???????????????????д???????str??