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

建设网站软件下载建筑工人找活正规平台

建设网站软件下载,建筑工人找活正规平台,推广网上国网,房地产破了后国家会怎样目录 换行符刷新缓冲区#xff08;c和c通用) 输入事件到来(c和c通用) 控制符flush(c特有) 控制符endl(c特有) c库函数#xff1a;fflush刷新缓冲区(c特有) sync(linux#xff09; fsync(linux) fdatasync (linux) 在使用printf或者cout等将数据输出到显示器上时c和c通用) 输入事件到来(c和c通用) 控制符flush(c特有) 控制符endl(c特有) c库函数fflush刷新缓冲区(c特有) sync(linux fsync(linux) fdatasync (linux) 在使用printf或者cout等将数据输出到显示器上时数据会先进入对应的输出缓冲区只有当缓冲区被刷新时数据才会真正来到显示器。 换行符刷新缓冲区c和c通用) #include iostream #include stdio.h #include unistd.h using namespace std;// 换行符刷新缓冲区 int main() {// cout不会直接将“123”输出到显示器上而是将其发送到输出缓冲区// 输出缓冲区收到换行符后会刷新输出缓冲区至显示器上// 也可以从面向对象的角度思考一下这个问题// 我想要输出一些数据到显示器上// cout用于将数据输出到显示器上// 可是我想一次发一个完整的数据给显示器那么什么时候才是这个完整的数据呢// \n告诉cout这个完整的数据我写完了你去发给显示器吧cout 123;sleep(3);cout \n;sleep(3);return 0; } 输入事件到来(c和c通用) #include iostream #include stdio.h #include unistd.h using namespace std;// 输入事件到来 int main() {// 当需要输入时会刷新输出缓冲区至显示器上cout enter a number: ;int a;cin a;return 0; } 控制符flush(c特有) #include iostream #include stdio.h #include unistd.h using namespace std;// 控制符flush int main() {cout 123;sleep(3);// cout flush; //---实际上ostream类对插入运算符进行了重载。cout flush被替换成flush(cout)flush(cout);sleep(3);return 0; } 控制符endl(c特有) #include iostream #include stdio.h #include unistd.h using namespace std;// 控制符endl int main() {// endl也会刷新cout对应的输出缓冲区至显示器上并添加换行符\ncout 123;sleep(3);cout endl;sleep(3);return 0; } c库函数fflush刷新缓冲区(c特有) #include iostream #include stdio.h #include unistd.h using namespace std;// c库函数fflush刷新缓冲区 // int fflush(FILE *stream); int main() {// endl也会刷新cout对应的输出缓冲区至显示器上并添加换行符\nprintf(123);sleep(3);fflush(stdout);sleep(3);return 0; } sync(linux 将所有文件已修改的数据从内核缓冲区写回存储设备将所有文件的元数据如文件大小、权限、时间戳等从内核缓冲区写回存储设备。 #include stdio.h #include stdlib.h #include fcntl.h #include unistd.h #include sys/sync.hint main() {int fd open(test.txt, O_WRONLY | O_CREAT, 0644);if (fd -1) {perror(open);return 1;}const char *message Hello, sync!;// write并不会把数据直接写入磁盘而是写入到该文件对应的内核缓冲区ssize_t bytes_written write(fd, message, sizeof(message) - 1);if (bytes_written -1) {perror(write);close(fd);return 1;}// 调用sync函数确保数据写入磁盘// 刷新所有内核缓冲区包括这个文件和其他文件对应的内核缓冲区// 会刷新每个文件对应的内核缓冲区至各自对应的磁盘区域上sync();close(fd);return 0; } fsync(linux) 将特定一个文件已修改的数据从内核缓冲区写回存储设备将特定一个文件的元数据如文件大小、权限、时间戳等从内核缓冲区写回存储设备。 #include stdio.h #include stdlib.h #include fcntl.h #include unistd.h #include sys/stat.hint main() {int fd open(test_fsync.txt, O_WRONLY | O_CREAT, 0644);if (fd -1) {perror(open);return 1;}const char *message Hello, fsync!;ssize_t bytes_written write(fd, message, sizeof(message) - 1);if (bytes_written -1) {perror(write);close(fd);return 1;}// 调用fsync函数确保该文件对应内核缓冲区数据和元数据写入磁盘if (fsync(fd) -1) {perror(fsync);close(fd);return 1;}close(fd);return 0; } 这里在写入数据后我们调用 fsync。fsync 会确保不仅文件内容数据被写入磁盘而且文件的元数据如文件大小、权限、时间戳等也被同步更新到磁盘。这对于需要严格一致性的应用场景非常重要比如文件系统的元数据更新操作。 fdatasync (linux) 只保证将特定一个文件对应的内核缓冲区中的数据写入到磁盘。 #include stdio.h #include stdlib.h #include fcntl.h #include unistd.h #include sys/stat.hint main() {int fd open(test_fdatasync.txt, O_WRONLY | O_CREAT, 0644);if (fd -1) {perror(open);return 1;}const char *message Hello, fdatasync!;ssize_t bytes_written write(fd, message, sizeof(message) - 1);if (bytes_written -1) {perror(write);close(fd);return 1;}// 调用fdatasync函数确保该文件内核缓冲区数据写入磁盘if (fdatasync(fd) -1) {perror(fdatasync);close(fd);return 1;}close(fd);return 0; }
http://www.dnsts.com.cn/news/251121.html

相关文章:

  • 装饰网站卧室做炕百度通信公司网站建设
  • 可以自己做网站服务器不珠海电商网站制作
  • 中山企业集团网站建设wordpress 评论时间
  • 手机网站跳出率低站长工具一区
  • 小游戏网站代码国内做优秀的农业信息网站
  • 安丘做网站的公司杭州做网站的优质公司
  • 网站建设 语言wordpress调用header
  • 做网站 就如何搭建一个局域网
  • 免费企业名录网站成都网站建设六六
  • 福建工程建设网站硅胶鞋垫移动网站建设
  • 网站推广优化软件学校网站搭建
  • 建设部网站首页百度引擎提交入口
  • 资源网站优化排名软件网络营销是什么的产物
  • 网站建设岗位廉政风险防控wordpress媒体库无法显示
  • 成品网站和模板建站阿里巴巴网
  • 北京泰达建设有限公司网站网站导航页怎么做
  • 公司网站怎么能被百度收录汽车行业网站怎么做
  • 哪里接单做网站做个网站app吗
  • 网站怎么做视频成都哪家网站建设强
  • 情侣博客网站模板下载东莞横沥网站设计
  • 二手车网站开发过程wordpress怎么提权
  • 百科wordpress营销型网站建设优化建站
  • 网页设计公司网站制作wordpress创建导航
  • 教育行业建设网站公司做公司网站宣传
  • 关于网站开发的文章浙江杭州最新消息
  • 网站制作新手教程pc手机模板网站建设
  • 网站的资讯内容济南网签查询系统
  • 新手做亚马逊要逛哪些网站濉溪建设投资网站
  • 中国建设銀行网站投诉电话临海网站制作好了如何上线
  • 网站建设与制作过程wordpress调用python脚本