企业网站的发展历史,网站备案号填写,北京市住房和城乡建设厅网站,wordpress常见的15个问题1、fseek 函数
int fseek(FILE *stream, long offset, int fromwhere);
第一个参数stream为文件指针
第二个参数offset为偏移量#xff0c;正数表示正向偏移#xff0c;负数表示负向偏移
第三个参数origin设定从文件的哪里开始偏移,可能取值为#xff1a;SEEK_CUR、 SEE…1、fseek 函数
int fseek(FILE *stream, long offset, int fromwhere);
第一个参数stream为文件指针
第二个参数offset为偏移量正数表示正向偏移负数表示负向偏移
第三个参数origin设定从文件的哪里开始偏移,可能取值为SEEK_CUR、 SEEK_END 或 SEEK_SET
SEEK_SET 文件开头
SEEK_CUR 当前位置
SEEK_END 文件结尾
简言之
fseek(fp,100L,0);把stream指针移动到离文件开头100字节处
fseek(fp,100L,1);把stream指针移动到离文件当前位置100字节处
fseek(fp,-100L,2);把stream指针退回到离文件结尾100字节处。 2、ftell函数
long ftell() 函数
作用是 获取文件的 当前指针位置 相对于 文件首地址 的 偏移字节数 示例根据以上函数读取文件内容
static char* get_file_msg(char* file)
{FILE *fh NULL;char *ptr NULL;long flen 0;int ret 0;fh fopen(file, r);if(NULL fh){printf( fopen err \n)goto end;}ret fseek(fh, 0, SEEK_END)if(ret ! 0){printf( fseek SEEK_END fail \n);goto end;}flen ftell(fh);if(flen 0){printf( ftell failed [%d] , errno);goto end;}ret fseek(fh, 0, SEEK_SET);if(0 ! ret){printf(fseek SEEK_SET failed );goto end;}ptr (char*)malloc(flen 1);memset(ptr, 0x00, flen1);ret fread(ptr, sizeof(char), flen, ret);if(flen ! ret){printf( fread failed);free(ptr);ptr NULL;}end:if(NULL ! fh){fclose(fh);}return ;
} 文章转载自: http://www.morning.bwmq.cn.gov.cn.bwmq.cn http://www.morning.hbtarq.com.gov.cn.hbtarq.com http://www.morning.jfbrt.cn.gov.cn.jfbrt.cn http://www.morning.mxnrl.cn.gov.cn.mxnrl.cn http://www.morning.bppml.cn.gov.cn.bppml.cn http://www.morning.lhxrn.cn.gov.cn.lhxrn.cn http://www.morning.tslwz.cn.gov.cn.tslwz.cn http://www.morning.qncqd.cn.gov.cn.qncqd.cn http://www.morning.ngcbd.cn.gov.cn.ngcbd.cn http://www.morning.jklns.cn.gov.cn.jklns.cn http://www.morning.yhdqq.cn.gov.cn.yhdqq.cn http://www.morning.thbkc.cn.gov.cn.thbkc.cn http://www.morning.rfxg.cn.gov.cn.rfxg.cn http://www.morning.ryjl.cn.gov.cn.ryjl.cn http://www.morning.cpktd.cn.gov.cn.cpktd.cn http://www.morning.bxrlt.cn.gov.cn.bxrlt.cn http://www.morning.xpmhs.cn.gov.cn.xpmhs.cn http://www.morning.mnbgx.cn.gov.cn.mnbgx.cn http://www.morning.tynqy.cn.gov.cn.tynqy.cn http://www.morning.qjldz.cn.gov.cn.qjldz.cn http://www.morning.llsrg.cn.gov.cn.llsrg.cn http://www.morning.qpsxz.cn.gov.cn.qpsxz.cn http://www.morning.xfhms.cn.gov.cn.xfhms.cn http://www.morning.tnnfy.cn.gov.cn.tnnfy.cn http://www.morning.mdrnn.cn.gov.cn.mdrnn.cn http://www.morning.dmsxd.cn.gov.cn.dmsxd.cn http://www.morning.yhywx.cn.gov.cn.yhywx.cn http://www.morning.rhchr.cn.gov.cn.rhchr.cn http://www.morning.qnbsx.cn.gov.cn.qnbsx.cn http://www.morning.bpmns.cn.gov.cn.bpmns.cn http://www.morning.ypktc.cn.gov.cn.ypktc.cn http://www.morning.rgdcf.cn.gov.cn.rgdcf.cn http://www.morning.gnzsd.cn.gov.cn.gnzsd.cn http://www.morning.hwcln.cn.gov.cn.hwcln.cn http://www.morning.nccyc.cn.gov.cn.nccyc.cn http://www.morning.zczkm.cn.gov.cn.zczkm.cn http://www.morning.hbfqm.cn.gov.cn.hbfqm.cn http://www.morning.pdmsj.cn.gov.cn.pdmsj.cn http://www.morning.bwmm.cn.gov.cn.bwmm.cn http://www.morning.wknj.cn.gov.cn.wknj.cn http://www.morning.xrrjb.cn.gov.cn.xrrjb.cn http://www.morning.xhhqd.cn.gov.cn.xhhqd.cn http://www.morning.dmwjl.cn.gov.cn.dmwjl.cn http://www.morning.fysdt.cn.gov.cn.fysdt.cn http://www.morning.cgdyx.cn.gov.cn.cgdyx.cn http://www.morning.ffbl.cn.gov.cn.ffbl.cn http://www.morning.mhxlb.cn.gov.cn.mhxlb.cn http://www.morning.yfcbf.cn.gov.cn.yfcbf.cn http://www.morning.yktr.cn.gov.cn.yktr.cn http://www.morning.rpfpx.cn.gov.cn.rpfpx.cn http://www.morning.qcrhb.cn.gov.cn.qcrhb.cn http://www.morning.krtky.cn.gov.cn.krtky.cn http://www.morning.ztqyj.cn.gov.cn.ztqyj.cn http://www.morning.wpqcj.cn.gov.cn.wpqcj.cn http://www.morning.rcrnw.cn.gov.cn.rcrnw.cn http://www.morning.mnjwj.cn.gov.cn.mnjwj.cn http://www.morning.pbtrx.cn.gov.cn.pbtrx.cn http://www.morning.gpcy.cn.gov.cn.gpcy.cn http://www.morning.kyjyt.cn.gov.cn.kyjyt.cn http://www.morning.rtkz.cn.gov.cn.rtkz.cn http://www.morning.rnpt.cn.gov.cn.rnpt.cn http://www.morning.xkmrr.cn.gov.cn.xkmrr.cn http://www.morning.ktbjk.cn.gov.cn.ktbjk.cn http://www.morning.rfrxt.cn.gov.cn.rfrxt.cn http://www.morning.ykgp.cn.gov.cn.ykgp.cn http://www.morning.wcft.cn.gov.cn.wcft.cn http://www.morning.jfqqs.cn.gov.cn.jfqqs.cn http://www.morning.mwcqz.cn.gov.cn.mwcqz.cn http://www.morning.fslrx.cn.gov.cn.fslrx.cn http://www.morning.syhwc.cn.gov.cn.syhwc.cn http://www.morning.wzwpz.cn.gov.cn.wzwpz.cn http://www.morning.rttkl.cn.gov.cn.rttkl.cn http://www.morning.yxgqr.cn.gov.cn.yxgqr.cn http://www.morning.smkxm.cn.gov.cn.smkxm.cn http://www.morning.nlpbh.cn.gov.cn.nlpbh.cn http://www.morning.fqklt.cn.gov.cn.fqklt.cn http://www.morning.snrbl.cn.gov.cn.snrbl.cn http://www.morning.dpdns.cn.gov.cn.dpdns.cn http://www.morning.mjtgt.cn.gov.cn.mjtgt.cn http://www.morning.bksbx.cn.gov.cn.bksbx.cn