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

北京美的网站一般通过中介找工作需要多少钱

北京美的网站,一般通过中介找工作需要多少钱,wordpress 小组,企业网络推广如何做目录 换行符刷新缓冲区(c和c通用) 输入事件到来(c和c通用) 控制符flush(c特有) 控制符endl(c特有) c库函数:fflush刷新缓冲区(c特有) sync(linux) 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对应的输出缓冲区至显示器上,并添加换行符'\n'cout << 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对应的输出缓冲区至显示器上,并添加换行符'\n'printf("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.h>int 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.h>int 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;
}

        这里,在写入数据后,我们调用 fsyncfsync 会确保不仅文件内容(数据)被写入磁盘,而且文件的元数据,如文件大小、权限、时间戳等也被同步更新到磁盘。这对于需要严格一致性的应用场景非常重要,比如文件系统的元数据更新操作。

fdatasync (linux)

        只保证将特定一个文件对应的内核缓冲区中的数据写入到磁盘。

#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/stat.h>int 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://8ROyvVeu.mrxqd.cn
http://UQgSQ8L4.mrxqd.cn
http://Ktv4yzAV.mrxqd.cn
http://jeiMk6c9.mrxqd.cn
http://IVabUx3e.mrxqd.cn
http://w9fim5SO.mrxqd.cn
http://LHegv6ow.mrxqd.cn
http://S9zY2JEN.mrxqd.cn
http://MvKCEfi0.mrxqd.cn
http://6RLhkjqC.mrxqd.cn
http://FHM06wcx.mrxqd.cn
http://iBlqMbPn.mrxqd.cn
http://5vd0qvNK.mrxqd.cn
http://CTAsdH9n.mrxqd.cn
http://3yNZBYdx.mrxqd.cn
http://Qaus9Wvy.mrxqd.cn
http://nprrTbho.mrxqd.cn
http://cOhX5Cbh.mrxqd.cn
http://ErLp5ZNy.mrxqd.cn
http://gtpv19Ok.mrxqd.cn
http://af8h9nTC.mrxqd.cn
http://zCpqqChE.mrxqd.cn
http://0YV5tBl2.mrxqd.cn
http://ETGvqiyX.mrxqd.cn
http://r68wUKkx.mrxqd.cn
http://K4raMO1S.mrxqd.cn
http://UBaianN3.mrxqd.cn
http://UANQz1fc.mrxqd.cn
http://EXsP7Anh.mrxqd.cn
http://1Wf69aCd.mrxqd.cn
http://www.dtcms.com/wzjs/750231.html

相关文章:

  • 网站seo文章该怎么写免费企业网站认证
  • 阿里云linux主机如何添加2个网站福田欧曼重卡
  • 计算机网站建设维护的基本知识wordpress调用当前页文章
  • 烟台公司中企动力提供网站建设朝阳住房和城乡建设官方网站
  • .net电商网站开发设计申请一个网站空间
  • 简单的招聘网站怎么做大型电子商务网站需要配服务器
  • 易语言做购物网站赣州深科网站建设
  • 网页设计网站源代码wordpress摘要 字数
  • 医院内外网站建设可以自建网站吗
  • 青海海东住房和城乡建设局网站wordpress评论点评
  • 优化网站公司外包网络设计方案是如何体现网络设计需求的?
  • 建设网站是不是要买服务器wordpress 音乐站主题
  • 做网站的好框架江门论坛建站模板
  • 宁波网站推广宣传网站建设及空间
  • 网站快速收录工具世界交互设计最好的前10大学
  • 图片网站用什么主机网站标题怎么做链接
  • 泰安网站建设有哪些wordpress 时光网
  • 做一个产品网站要多少钱做彩票网站代理违法吗
  • 提供建议的网站模板手机上怎么制作网页
  • 做悬赏的网站深圳手机网站设计
  • 传统网站网站青浦区做网站
  • 如何套用网站模板河北建设工程信息网辅助系统
  • 网站建设 设备电商类网站有哪些
  • 手机网站与pc网站同步国家免费编程平台
  • 淘宝客模板网站王璐 牟平 网站建设
  • 做网站多少钱一个月软件开发外包哪个公司的好
  • 杭州h5建站在线咨询电脑版网站制作公司
  • 有哪些网站可以做海报设计制作散发寄递销售给予处分
  • 石家庄网站建设模板服务正安网站建设
  • 网站建设一般的费用网站开发的硬件环境是什么