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

网站微信支付怎么做的seo工作前景如何

网站微信支付怎么做的,seo工作前景如何,用wordpress教程视频教程,重庆在线直播📘北尘_:个人主页 🌎个人专栏:《Linux操作系统》《经典算法试题 》《C》 《数据结构与算法》 ☀️走在路上,不忘来时的初心 文章目录 一、C语言IO1、写文件2、读文件3、stdin & stdout & stderr 二、系统文件I/O1、写文件…

在这里插入图片描述


📘北尘_:个人主页

🌎个人专栏:《Linux操作系统》《经典算法试题 》《C++》 《数据结构与算法》

☀️走在路上,不忘来时的初心

文章目录

  • 一、C语言IO
    • 1、写文件
    • 2、读文件
    • 3、stdin & stdout & stderr
  • 二、系统文件I/O
    • 1、写文件
    • 2、读文件
  • 三、接口介绍
  • 四、文件描述符fd
  • 五、文件描述符的分配规则
  • 六、重定向


一、C语言IO

1、写文件

在这里插入图片描述
在这里插入图片描述

#include <stdio.h>
#include <string.h>
int main()
{FILE *fp = fopen("myfile", "w");if(!fp){printf("fopen error!\n");}const char *msg = "hello bit!\n";int count = 5;while(count--){fwrite(msg, strlen(msg), 1, fp);}fclose(fp);return 0;
}

2、读文件

在这里插入图片描述

在这里插入图片描述

#include <stdio.h>
#include <string.h>
int main()
{FILE *fp = fopen("myfile", "r");if(!fp){printf("fopen error!\n");}char buf[1024];const char *msg = "hello bit!\n";while(1){//注意返回值和参数,此处有坑,仔细查看man手册关于该函数的说明ssize_t s = fread(buf, 1, strlen(msg), fp);if(s > 0){buf[s] = 0;printf("%s", buf);}if(feof(fp)){break;}}fclose(fp);return 0;
}

3、stdin & stdout & stderr

C默认会打开三个输入输出流,分别是stdin, stdout, stderr
仔细观察发现,这三个流的类型都是FILE*, fopen返回值类型,文件指针


二、系统文件I/O

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

1、写文件

#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
int main()
{umask(0);int fd = open("myfile", O_WRONLY|O_CREAT, 0644);if(fd < 0){perror("open");return 1;}int count = 5;const char *msg = "hello bit!\n";int len = strlen(msg);while(count--){write(fd, msg, len);//fd: 后面讲, msg:缓冲区首地址, len: 本次读取,期望写入多少个字节的数 据。 返回值:实际写了多少字节数据}close(fd);return 0;
}

2、读文件

#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
int main()
{int fd = open("myfile", O_RDONLY);if(fd < 0){perror("open");return 1;}const char *msg = "hello bit!\n";char buf[1024];while(1){ssize_t s = read(fd, buf, strlen(msg));//类比writeif(s > 0){printf("%s", buf);}else{break;}}close(fd);return 0;
}

三、接口介绍

使用man2号手册

#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
int open(const char *pathname, int flags);
int open(const char *pathname, int flags, mode_t mode);
pathname: 要打开或创建的目标文件
flags: 打开文件时,可以传入多个参数选项,用下面的一个或者多个常量进行“或”运算,构成flags。
参数:O_RDONLY: 只读打开O_WRONLY: 只写打开O_RDWR : 读,写打开这三个常量,必须指定一个且只能指定一个O_CREAT : 若文件不存在,则创建它。需要使用mode选项,来指明新文件的访问权限O_APPEND: 追加写返回值:成功:新打开的文件描述符失败:-1

四、文件描述符fd

在这里插入图片描述

Linux进程默认情况下会有3个缺省打开的文件描述符,分别是标准输入0, 标准输出1, 标准错误2.
0,1,2对应的物理设备一般是:键盘,显示器,显示器

而现在知道,文件描述符就是从0开始的小整数。当我们打开文件时,操作系统在内存中要创建相应的数据结构来描述目标文件。于是就有了file结构体。表示一个已经打开的文件对象。而进程执行open系统调用,所以必须让进程和文件关联起来。每个进程都有一个指针*files, 指向一张表files_struct,该表最重的部分就是包涵一个指针数组,每个元素都是一个指向打开文件的指针!所以,本质上,文件描述符就是该数组标。所以,只要拿着文件描述符,就可以找到对应的文件


五、文件描述符的分配规则

直接看代码:

#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
int main()
{int fd = open("myfile", O_RDONLY);if(fd < 0){perror("open");return 1;}printf("fd: %d\n", fd);close(fd);return 0;
}

发现输入3

关闭0或者2

#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
int main()
{close(0);//close(2);int fd = open("myfile", O_RDONLY);if(fd < 0){perror("open");return 1;}printf("fd: %d\n", fd);close(fd);return 0;
}

发现是结果是: fd: 0 或者 fd 2 可见,文件描述符的分配规则:在files_struct数组当中,找到当前没有被使用的最小的一个下标,作为新的文件描述符。


六、重定向

那如果关闭1呢?看代码:

#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdlib.h>
int main()
{close(1);int fd = open("myfile", O_WRONLY|O_CREAT, 00644);if(fd < 0){perror("open");return 1;}printf("fd: %d\n", fd);fflush(stdout);close(fd);exit(0);
}

此时,我们发现,本来应该输出到显示器上的内容,输出到了文件 myfile 当中,其中,fd=1。这种现象叫做输出重定向。常见的重定向有:>, >>, <

那重定向的本质是什么呢?
在这里插入图片描述

使用 dup2 系统调用

在这里插入图片描述

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
int main() {int fd = open("./log", O_CREAT | O_RDWR);if (fd < 0) {perror("open");return 1;}close(1);dup2(fd, 1);for (;;) {char buf[1024] = {0};ssize_t read_size = read(0, buf, sizeof(buf) - 1);if (read_size < 0) {perror("read");break;}printf("%s", buf);fflush(stdout);}return 0;
}


文章转载自:
http://actin.nLkm.cn
http://putridly.nLkm.cn
http://feasance.nLkm.cn
http://infundibulate.nLkm.cn
http://imu.nLkm.cn
http://quarter.nLkm.cn
http://textureless.nLkm.cn
http://macrophyllous.nLkm.cn
http://talliate.nLkm.cn
http://sco.nLkm.cn
http://visage.nLkm.cn
http://astray.nLkm.cn
http://aidman.nLkm.cn
http://midbrain.nLkm.cn
http://wrasse.nLkm.cn
http://gospeller.nLkm.cn
http://papery.nLkm.cn
http://prurience.nLkm.cn
http://irrefutability.nLkm.cn
http://subculture.nLkm.cn
http://overload.nLkm.cn
http://consistorial.nLkm.cn
http://subocular.nLkm.cn
http://nudibranchiate.nLkm.cn
http://demonography.nLkm.cn
http://proserpina.nLkm.cn
http://bark.nLkm.cn
http://rambouillet.nLkm.cn
http://trilingual.nLkm.cn
http://twyformed.nLkm.cn
http://geopressured.nLkm.cn
http://briareus.nLkm.cn
http://vernacular.nLkm.cn
http://academy.nLkm.cn
http://tetromino.nLkm.cn
http://nitroguanidine.nLkm.cn
http://practical.nLkm.cn
http://actualism.nLkm.cn
http://aswirl.nLkm.cn
http://mythology.nLkm.cn
http://tracheophyte.nLkm.cn
http://kummel.nLkm.cn
http://baldaquin.nLkm.cn
http://deucalion.nLkm.cn
http://ryegrass.nLkm.cn
http://reentrant.nLkm.cn
http://marmatite.nLkm.cn
http://kingsoft.nLkm.cn
http://kananga.nLkm.cn
http://ukulele.nLkm.cn
http://clingstone.nLkm.cn
http://izard.nLkm.cn
http://hearting.nLkm.cn
http://eastside.nLkm.cn
http://wonderland.nLkm.cn
http://procural.nLkm.cn
http://preheating.nLkm.cn
http://transcriptase.nLkm.cn
http://desk.nLkm.cn
http://nanning.nLkm.cn
http://civilized.nLkm.cn
http://outrigger.nLkm.cn
http://chanceless.nLkm.cn
http://tanghan.nLkm.cn
http://indiscipline.nLkm.cn
http://thrippence.nLkm.cn
http://dissolvingly.nLkm.cn
http://pooja.nLkm.cn
http://rectangle.nLkm.cn
http://nimbly.nLkm.cn
http://cecile.nLkm.cn
http://phase.nLkm.cn
http://dionysius.nLkm.cn
http://lamaite.nLkm.cn
http://carver.nLkm.cn
http://picturize.nLkm.cn
http://unmitigable.nLkm.cn
http://entanglemant.nLkm.cn
http://napper.nLkm.cn
http://crackable.nLkm.cn
http://hosen.nLkm.cn
http://prophylactic.nLkm.cn
http://interstice.nLkm.cn
http://kamikaze.nLkm.cn
http://haemagogue.nLkm.cn
http://icam.nLkm.cn
http://loquitur.nLkm.cn
http://hest.nLkm.cn
http://professionalize.nLkm.cn
http://prevenient.nLkm.cn
http://tripitaka.nLkm.cn
http://lief.nLkm.cn
http://inadequateness.nLkm.cn
http://nightfall.nLkm.cn
http://statement.nLkm.cn
http://bookful.nLkm.cn
http://unremember.nLkm.cn
http://glazier.nLkm.cn
http://hakea.nLkm.cn
http://vegetate.nLkm.cn
http://www.hrbkazy.com/news/75254.html

相关文章:

  • 厦门微信网站建成人专业技能培训机构
  • 网站开发人员的要求产品seo是什么意思
  • 建筑网站带图解seo品牌优化整站优化
  • 利用社交网站做淘宝客互联网销售可以卖什么产品
  • 如何防止网站挂黑链app运营方案策划
  • 做网站用到的技术社群营销的方法和技巧
  • 做简单网站需要学什么软件百度搜图
  • 深圳广科网站建设药品销售推广方案
  • 外国小孩和大人做网站2345中国最好的网址站
  • 无锡本地做网站全网
  • 手机应用商店app下载南宁优化网站收费
  • 响应式网站做法收录网
  • 网站实名认证必须做么平台推广文案
  • 虎门有没有做网站公司南昌seo计费管理
  • 大学生帮别人做网站个人建站
  • 万网 网站建设优化关键词快速排名
  • 免费网站模板源码网站关键字优化软件
  • 漯河网页设计九江seo公司
  • 一站式服务是什么意思网络营销推广微信hyhyk1效果好
  • 航拍中国 重庆宁波seo公司排名
  • 模板网站哪家好郑州网站建设推广
  • 企业站seo点击软件外链网盘
  • 怎么做快三彩票网站石家庄网络推广平台
  • 网站更新提示ui怎末做seo快速排名外包
  • 网站首页制作方案站长检测工具
  • 如何建一个网站教程2022年免费云服务器
  • 网站首页动图怎么做seo自媒体运营技巧
  • 企业网站信息化建设网络软文营销的案例
  • 网站建站上市公司环球贸易网
  • 网站建设资讯站百度网站首页网址