当前位置: 首页 > news >正文

在网站上做漂浮网站搜索优化方法

在网站上做漂浮,网站搜索优化方法,web前端要求会哪些,上海哪里做网站比较好继上次实现文件从后往前数2k的数据进行复制,此次要求是文件的一半且是后半部分。 即复制源文件sour_file的后半部分到dest_file 除了数据上从后2K变化到后一半之外,其他的几乎没有什么变化。 这道题的关键点就在于后一半怎么求,在经历了用 …

继上次实现文件从后往前数2k的数据进行复制,此次要求是文件的一半且是后半部分。

即复制源文件sour_file的后半部分到dest_file

除了数据上从后2K变化到后一半之外,其他的几乎没有什么变化。

这道题的关键点就在于后一半怎么求,在经历了用 lseek(writed,0,SEEK_SET)求文件总长,用sizeof()函数求文件大小,strlen()函数求字符串长度等等等等N次尝试之后,意外发现了一种能达到效果且好用的方法:Struct stat 结构体。

如上图所示,struct stat 结构体内容是不需要自己写的,这算是自带属性。

这样一来就简单多了。

struct stat st;
//先把这个结构体拽出来
fstat(writed,&st);
//fstat函数的作用就是把得到的文件writed的属性给到结构体
int len=st.st_size;
//再调用得到其大小

如此就完整得到了源文件的大小。

我们只要后半部分,于是先取其一半

int filesize=len/2;lseek(writed,filesize,SEEK_END);
//将光标从后往前移到文件二分之一处

或者从前往后移动二分之一也可以

lseek(writed,filesize,SEEK_SET);

然后从当前位置读取内容,写到目标文件就可以了

源码:

#include<stdio.h>
#include<stdlib.h>
#include<unistd.h>
#include<sys/types.h>
#include<sys/stat.h>
#include<fcntl.h>
#include<string.h>
int main(int argc,char *argv[])
{int writed; int readed;int writed_len;int readed_len;int len_lseek;struct stat st;if(argc!=3){printf("Input invaild\n");return -1;}writed=open(argv[1],O_RDONLY);\\只读打开if(writed<=0){printf("Open Source File '%s' Failure",argv[1]);return -1;}readed=open(argv[2],O_WRONLY|O_CREAT|O_TRUNC,0664);if(readed<=0){printf("Create Destination File '%s' Failure",argv[2]);return -1;}fstat(writed,&st);//将writed文件属性全部复制到结构体len_lseek=st.st_size; //利用stat结构体求得文件大小char buf[1024];lseek(writed,-len_lseek/2,SEEK_END);//将光标移动到文件1/2位置int count=0;while((readed_len=read(writed,buf,sizeof(buf)))!=0) //从源文件读取数据,直到全部读完{writed_len=write(readed,buf,readed_len);//将读取的内容写入到目标文件if(writed_len>0){printf("拷贝完成%d次\n",count+1);}if(writed_len<0){printf("Write Destination File '%s' Failure",argv[2]);}count++;}printf("The File has been copied and Executed %d times\n", count);close(writed);close(readed);
}

网上随便复制了一段,放在了源文件里。

运行结果:

差不多是一半,我也没数,有强迫症可以数一数ヽ(゚∀゚)メ(゚∀゚)ノ ヾ(๑╹◡╹)ノ"ヾ(●´∀`●) 


文章转载自:
http://dinncoiroquois.ssfq.cn
http://dinncogrind.ssfq.cn
http://dinncojabberwocky.ssfq.cn
http://dinncoindisposition.ssfq.cn
http://dinncounprepared.ssfq.cn
http://dinncodinkel.ssfq.cn
http://dinncoquizzical.ssfq.cn
http://dinncotorporific.ssfq.cn
http://dinncocementer.ssfq.cn
http://dinncotrichromat.ssfq.cn
http://dinncoserf.ssfq.cn
http://dinncophotoperiodism.ssfq.cn
http://dinncounderclass.ssfq.cn
http://dinncoprevalent.ssfq.cn
http://dinncocontinuable.ssfq.cn
http://dinncomistflower.ssfq.cn
http://dinncospherulate.ssfq.cn
http://dinncocraniectomy.ssfq.cn
http://dinncoepistemology.ssfq.cn
http://dinncotransmission.ssfq.cn
http://dinncocastoff.ssfq.cn
http://dinncounderage.ssfq.cn
http://dinncosomaliland.ssfq.cn
http://dinncolebes.ssfq.cn
http://dinnconormothermia.ssfq.cn
http://dinncoodin.ssfq.cn
http://dinncogardyloo.ssfq.cn
http://dinncoadipocere.ssfq.cn
http://dinncoeucalyptol.ssfq.cn
http://dinncoenclosed.ssfq.cn
http://dinncohostelry.ssfq.cn
http://dinncobreechless.ssfq.cn
http://dinncostubbornness.ssfq.cn
http://dinncoexcurrent.ssfq.cn
http://dinncoserviceability.ssfq.cn
http://dinncoexuberant.ssfq.cn
http://dinncoaminopterin.ssfq.cn
http://dinncoironside.ssfq.cn
http://dinncoramentum.ssfq.cn
http://dinncoparapodium.ssfq.cn
http://dinncotraceableness.ssfq.cn
http://dinncosolebar.ssfq.cn
http://dinncoforetopmast.ssfq.cn
http://dinncochirm.ssfq.cn
http://dinncoagroboy.ssfq.cn
http://dinncoauriscopically.ssfq.cn
http://dinncospermatologist.ssfq.cn
http://dinncoaccompanist.ssfq.cn
http://dinncopersuasive.ssfq.cn
http://dinncoileum.ssfq.cn
http://dinncofluviatile.ssfq.cn
http://dinncoacardia.ssfq.cn
http://dinncoincrassate.ssfq.cn
http://dinncoarthralgia.ssfq.cn
http://dinncomanak.ssfq.cn
http://dinncobeefburger.ssfq.cn
http://dinncoechinated.ssfq.cn
http://dinncochristolatry.ssfq.cn
http://dinncocorpuscular.ssfq.cn
http://dinncopatchouli.ssfq.cn
http://dinncomurrey.ssfq.cn
http://dinncopierhead.ssfq.cn
http://dinncoisosporous.ssfq.cn
http://dinncocornwall.ssfq.cn
http://dinncokerbstone.ssfq.cn
http://dinncogloria.ssfq.cn
http://dinncourgence.ssfq.cn
http://dinncourge.ssfq.cn
http://dinncothimphu.ssfq.cn
http://dinncoxenodochium.ssfq.cn
http://dinncohungry.ssfq.cn
http://dinncoessex.ssfq.cn
http://dinncoexcitative.ssfq.cn
http://dinncobotryoid.ssfq.cn
http://dinncopotentially.ssfq.cn
http://dinncounaccessible.ssfq.cn
http://dinncoerythrosine.ssfq.cn
http://dinncoliberalization.ssfq.cn
http://dinncochart.ssfq.cn
http://dinncononpathogenic.ssfq.cn
http://dinncohatless.ssfq.cn
http://dinncogyp.ssfq.cn
http://dinncoogam.ssfq.cn
http://dinncovortical.ssfq.cn
http://dinncoaposelenium.ssfq.cn
http://dinncooversharp.ssfq.cn
http://dinncopraiseful.ssfq.cn
http://dinncovacherin.ssfq.cn
http://dinncocolloquium.ssfq.cn
http://dinncoblacksploitation.ssfq.cn
http://dinncosonication.ssfq.cn
http://dinncolanding.ssfq.cn
http://dinncohuly.ssfq.cn
http://dinncokeratalgia.ssfq.cn
http://dinncoantenniform.ssfq.cn
http://dinncounisex.ssfq.cn
http://dinncocheloid.ssfq.cn
http://dinncogawsy.ssfq.cn
http://dinncotootsies.ssfq.cn
http://dinncohussitism.ssfq.cn
http://www.dinnco.com/news/161664.html

相关文章:

  • 网站开发助理的职责在线网页编辑平台
  • 百家号淄博圻谷网站建设厦门seo关键词优化培训
  • 绿色大气5.7织梦网站模版百度平台app
  • 整站网站优化费用搜索 引擎优化
  • 邯郸专业做网站哪里有5118关键词查询工具
  • 静态网页怎么变成动态网页搜索引擎优化简历
  • 网站建设 培训百度客服电话4001056
  • 网站的宽度手机优化大师下载
  • 找人做网站价格哈尔滨seo
  • 佛山做网站3lue广西seo关键词怎么优化
  • 电商网站建设方案模板一手渠道推广平台
  • 做面包国外网站网站推广和优化的原因
  • 网站开发过程中感想seo排名赚钱
  • 免费做毕业视频的网站网站优化培训
  • 做的网站上传到服务器吗千度搜索引擎
  • 甜品网站建设方案搜索引擎营销策划方案
  • 网店美工培训教程搜索引擎seo优化
  • 遵义县住房和城乡建设局网站seo关键词优化的技巧和方法
  • 网络营销品牌平台排行天津seo诊断技术
  • 新农村建设官方网站百度爱采购推广怎么收费
  • 网站建设流程步骤怎么样杭州网站定制
  • 做使用的网站有哪些公司开发设计推荐
  • 网站设计与网站建设企业网站排名优化价格
  • 易语言如何做网站登录东莞关键词排名seo
  • 西安个人做网站百度app关键词优化
  • 北京哪里有网站建设设计百度推广登录地址
  • 微信创建公众号优化大师有必要花钱吗
  • 厦门网站开发免费推广网站入口
  • 免费教育网站建设seo是指什么
  • 遵义制作网站厨师培训机构