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

微信网页版网址seo自动工具

微信网页版网址,seo自动工具,贵州网站建设 零玖伍壹网络,网站倍攻击1. 知识点 读入写出,切记以我们程序为中心向文件或者别的什么东西读入写出(输入流输出流) 人话就是 文件向我们程序就是读入 程序向文件或者别的什么就是写出 2. open打开文件 open.c /****************************************************…

1. 知识点

读入写出,切记以我们程序为中心向文件或者别的什么东西读入写出(输入流输出流)

人话就是

文件向我们程序就是读入

程序向文件或者别的什么就是写出

2. open打开文件

open.c

/*************************************************************************> File Name: open.c> Author: lsf> Mail: lsf_2012@163.com > Created Time: 2023年10月20日 星期五 10时30分06秒************************************************************************/#include<stdio.h>
#include<unistd.h>
#include<sys/types.h>
#include<sys/stat.h>
#include<fcntl.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

#include<stdio.h>
#include<unistd.h>
#include<sys/types.h>
#include<sys/stat.h>
#include<fcntl.h>
#include<string.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(ret==0){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(i=1;i<argc;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

#include<stdio.h>
#include<unistd.h>
#include<sys/types.h>
#include<sys/stat.h>
#include<fcntl.h>
#include<string.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(n==0){close(fd1);close(fd2);break;}}return 0;
}

5. lseek光标函数

lseek.c

#include<stdio.h>
#include<unistd.h>
#include<sys/types.h>
#include<sys/stat.h>
#include<fcntl.h>
#include<string.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

#include<stdio.h>
#include<unistd.h>
#include<sys/types.h>
#include<sys/stat.h>
#include<fcntl.h>
#include<string.h>//自我实现copy函数int main(int argc, char **argv)
{if(argc == 1){printf("请给我至少一个文件的路径\n");return 0;}int i=0;for(i=1;i<argc;i+=2){int fd1 = open(argv[i],O_RDONLY);int fd2 = open(argv[i+1],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(n==0){close(fd1);close(fd2);break;}}}return 0;
}

7.2 自我实现两个文件的比较diff函数

#include<stdio.h>
#include<unistd.h>
#include<sys/types.h>
#include<sys/stat.h>
#include<fcntl.h>
#include<string.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(n1==0){close(fd1);break;}if(n2==0){close(fd2);break;}}//至此if(flag){printf("两个文件不同\n");}else{printf("两文件相同\n");}return 0;
}

http://www.15wanjia.com/news/11752.html

相关文章:

  • 古诗网页制作教程郑州seo线上推广技术
  • 网站建设合同应注意什么网站查找工具
  • 网站托管平台每日新闻摘要30条
  • 做二手物资哪个网站好泉州百度推广咨询
  • 宽屏网站模板在广州做seo找哪家公司
  • 怎么把网站做10万ip适合发朋友圈的营销广告
  • 唐山建设网站公司百度seo排名优化系统
  • 做网站后台运营这个工作怎么样免费发帖推广平台
  • 免费下载b站视频软件广告公司
  • 专门做童装的网站网络平台怎么创建
  • 魔兽做图下载网站互动营销成功案例
  • 树莓派做影视网站软文营销广告案例
  • 可以做旅游供应商的网站域名注册需要多久
  • 建立一个网站需要会什么软件如何自己开发一个网站
  • 国家图书馆网站做的好垃圾太原seo排名
  • 网站建设需求确认表关键词推广seo怎么优化
  • 外贸英文商城网站建设品牌运营管理公司
  • 响应式网站做优化好吗营销策略范文
  • 网站备案需要资料百度官网认证多少钱一年
  • 新建网站如何调试小视频关键词汇总
  • 湖北网站注册设计公司郑州seo技术代理
  • 那个视频网站可以做gif地推网app推广平台
  • 网站设计方案和技巧长沙网站定制公司
  • 如何做网站霸屏免费外链生成器
  • 网站备案查询工信部app可以免费发外链的论坛
  • wordpress 代码块样式廊坊网络推广优化公司
  • 郑州网站优化推广新手怎么做网络推广
  • bootstrap 企业门户网站成人厨师短期培训班
  • 建湖做网站哪家公司好运营推广seo招聘
  • 网站开发视频转码谷歌浏览器下载官方正版