我需要声明多少次 std::ios::sync_with_stdio(假);在程序中
How many times would I need to declare std::ios::sync_with_stdio(false); in a program
所以,我正在研究一些使我的代码运行更快的方法,我发现printf
比cout
更快。但是,我看到了std::ios::sync_with_stdio(false);
通过不同步使 cout 更快。
我现在的问题是:您是否需要在 main 中声明它并且它适用于我的整个程序,或者我需要使用 cout
将其放置在每个函数中,还是我需要将其放置在每个cout
之前?
在执行任何 I/O 操作之前,您只需要将其放置一次,最好放在 main 中,因为:
如果在标准流上发生 I/O 后调用此函数,则行为由实现定义
相关文章:
- Mongodb c++驱动程序:如何查询元素的数组
- C++,系统无法执行指定的程序
- 在C++程序中输入的文本文件将不起作用,除非文本被复制和粘贴
- 在VS代码中交叉编译Windows与Linux上的MinGW的SDL程序
- C++ Windows 驱动程序MSB3030无法复制该文件,因为它找不到
- 重载操作程序时出错>>用于类中的字符串 memebr
- 获取日期异步信号安全吗?如果在信号处理程序中使用,它会导致死锁吗
- 试图在visual studio上用C++创建一个桌面应用程序
- 模板元程序查找相似的连续类型名称
- FFmpeg:制作一个应用程序比直接使用ffmepg更好吗
- 如何通过cpp程序运行shell脚本
- 有没有什么方法可以使用一个函数中定义的常量变量,也可以由c++中同一程序中的其他函数使用
- IPC使用多个管道和分支进程来运行Python程序
- 如何将c++程序的一些输出传递给shell,以便在shell中使用
- 使用C++程序合并排序没有得到正确的输出
- 与 stdio 同步是否使程序 I/O 非交互式?
- 是否可以使用stdio函数读取Windows应用商店应用程序中的资产
- 为什么VC++ 2010 Express在这个程序中不需要stdio.h,而gcc++需要?
- Eclipse for c安装程序,无法定位stdio.h
- 新安装的VS 2012将不会构建默认的控制台应用程序:缺少SDKDDKVer.h(和stdio.h / CRT)