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

快速建站的模板网站全站开发需要学什么

快速建站的模板,网站全站开发需要学什么,百度搜索引擎优化案例,百度智能云windows系统服务器建站1. 知识点 读入写出#xff0c;切记以我们程序为中心向文件或者别的什么东西读入写出#xff08;输入流输出流#xff09; 人话就是 文件向我们程序就是读入 程序向文件或者别的什么就是写出 2. open打开文件 open.c /****************************************************… 1. 知识点 读入写出切记以我们程序为中心向文件或者别的什么东西读入写出输入流输出流 人话就是 文件向我们程序就是读入 程序向文件或者别的什么就是写出 2. open打开文件 open.c /************************************************************************* File Name: open.c Author: lsf Mail: lsf_2012163.com Created Time: 2023年10月20日 星期五 10时30分06秒************************************************************************/#includestdio.h #includeunistd.h #includesys/types.h #includesys/stat.h #includefcntl.h//使用open函数 int main() {//打开文件---1.txt文件存在int fd1 open(./1.txt,O_RDWR);//创建文件int fd2 open(./2.txt,O_RDWR | O_CREAT,0777);printf(fd1 %d fd2 %d\n,fd1,fd2);//关闭文件close(fd1);close(fd2);return 0; } 3. read读入文件 read.c #includestdio.h #includeunistd.h #includesys/types.h #includesys/stat.h #includefcntl.h #includestring.h//使用read函数 int main() {//打开文件---1.txt文件存在int fd1 open(./1.txt,O_RDWR);char buf[10]{0};//读文件while(1){memset(buf,0,sizeof(buf));//清空缓存区ssize_t ret read(fd1,buf,sizeof(buf)-1);printf(%s,buf);if(ret0){break;}}//关闭文件close(fd1);return 0; } 3.2 实现cat函数 cat.c #include sys/types.h #include sys/stat.h #include fcntl.h #include stdio.h #include unistd.h #include string.h//自己写一个cat函数int main(int argc, char **argv)//cat.out 1.txt 2.txt 3.txt 4.txt { //argv[0] argv[1] argv[2]if(argc 1){printf(请给我至少一个文件的路径\n);return 0;}int i;for(i1;iargc;i){int fd1 open(argv[i],O_RDWR);char buf[10] {0};while(1){memset(buf,0,sizeof(buf));//内存重置,清空bzero(buf,sizeof(buf));ssize_t n read(fd1,buf,sizeof(buf)-1);printf(%s,buf);//退出条件if(n 0){close(fd1);break;}}} } 4. write写出文件 write.c #includestdio.h #includeunistd.h #includesys/types.h #includesys/stat.h #includefcntl.h #includestring.h//使用write函数实现文件的复制int main() {int fd1 open(./1.txt,O_RDONLY);int fd2 open(./2.txt,O_WRONLY|O_CREAT,0777);char buf[10];//文件的复制while(1){//内存清空memset(buf,0,sizeof(buf));//读文件ssize_t n read(fd1,buf,sizeof(buf)-1);//写文件write(fd2,buf,strlen(buf));if(n0){close(fd1);close(fd2);break;}}return 0; }5. lseek光标函数 lseek.c #includestdio.h #includeunistd.h #includesys/types.h #includesys/stat.h #includefcntl.h #includestring.h//使用lseek函数int main() {int fd1 open(./4.txt,O_RDWR|O_CREAT,0777);char buf[12] hello world;char buf2[12];//写文件write(fd1,buf,strlen(buf));lseek(fd1,0,SEEK_SET);//使光标复位到起始为止//读文件memset(buf2,0,sizeof(buf2));//清空缓存区read(fd1,buf2,sizeof(buf2));printf(%s\n,buf2);close(fd1);return 0; }6. perror错误打印函数 7. 练习 7.1 自我实现多个文件一起复制 copy函数 my_copy.c #includestdio.h #includeunistd.h #includesys/types.h #includesys/stat.h #includefcntl.h #includestring.h//自我实现copy函数int main(int argc, char **argv) {if(argc 1){printf(请给我至少一个文件的路径\n);return 0;}int i0;for(i1;iargc;i2){int fd1 open(argv[i],O_RDONLY);int fd2 open(argv[i1],O_WRONLY|O_CREAT,0777);char buf[12];//文件的复制while(1){//内存清空memset(buf,0,sizeof(buf));//读文件ssize_t n read(fd1,buf,sizeof(buf)-1);//写文件write(fd2,buf,strlen(buf));if(n0){close(fd1);close(fd2);break;}}}return 0; } 7.2 自我实现两个文件的比较diff函数 #includestdio.h #includeunistd.h #includesys/types.h #includesys/stat.h #includefcntl.h #includestring.h//自我实现diff函数int main(int argc,char** argv) {if(argc 1){printf(请给我至少一个文件的路径\n);return 0;}//打开两个文件int fd1 open(argv[1],O_RDONLY);int fd2 open(argv[2],O_RDONLY);char buf1[5] {0};char buf2[5] {0};int flag 0;//两文件相同while(1){//读取文件memset(buf1,0,sizeof(buf1));memset(buf2,0,sizeof(buf2));ssize_t n1 read(fd1,buf1,sizeof(buf1)-1);ssize_t n2 read(fd2,buf2,sizeof(buf2)-1);//比较读取出来的bufif(strcmp(buf1,buf2)!0){flag 1;//不同break;}if(n10){close(fd1);break;}if(n20){close(fd2);break;}}//至此if(flag){printf(两个文件不同\n);}else{printf(两文件相同\n);}return 0; }
http://www.yingshimen.cn/news/75627/

相关文章:

  • 山东莱钢建设有限公司网站建筑网站招聘
  • 德化规划与建设局网站寻模板网站源码
  • 网站运营教程怎么注册网址免费
  • 网站建设地图怎么设置网站开发用户自定义排序方案
  • 网站模块是指什么地方做哪个网站有效果
  • 0基础网站建设模板网站建设教学工作总结6
  • 怎么把自己做的网站挂到外网上如何开通免费网站
  • 网站服务器租用资质常用网站推广方法的适用性
  • django企业级问答网站开发wordpress插件 下载
  • dw设计做网站完整案例深圳o2o网站建设
  • 北京长空建设有限公司网站网站域名指什么
  • 青岛网站开发中心淮阳城乡建设局网站
  • 企业级网站欣赏做我的奴隶 good网站
  • 济南网站优化推广方案网站开发什么课程
  • 青岛品牌网站制作成都seo推广员
  • tomcat做网站并发辽宁朝阳网站建设
  • 蓝图网站建设红黑配色网站
  • 神农架网站建设公司深圳网站建设 找猴王网络
  • mooc网站开发ppt古镇企业网站建设定制
  • wix怎样做网站网站开发常用软件是什么
  • 网页制作与网站建设pdfwordpress导入图片不显示
  • 房地产网站大全用ps做网站得多大像素
  • 网站备案服务商查询门户网站前台页面
  • 深圳网站建设top028用什么程序做网站
  • 南京做网站企业郑州航空港建设局网站
  • 购物网站建设 成都莱芜找工作 招聘附近
  • 厦门行业网站建设怎么在雅虎做网站收入
  • 普达建站快车wordpress文章更新软件
  • 全球设计网站排行做网站需要的技能
  • 唯品会购物网站开发项目河北省建设厅官方网站 官网