C++延时函数
2016-05-31 11:25
288 查看
这个系列想写一些C++编程中常用的小程序。
C++标准库没有延时函数,我们可以利用clock()函数实现延时。
使用clock函数需要包含time.h。
void delay_ms(int ms)
{
clock_t start = clock();
while (clock() - start < ms);
}
C++标准库没有延时函数,我们可以利用clock()函数实现延时。
使用clock函数需要包含time.h。
void delay_ms(int ms)
{
clock_t start = clock();
while (clock() - start < ms);
}
相关文章推荐
- 感知机c/c++代码实现
- c++中this指针的用法详解
- C/C++中extern关键字详解
- C/C++中const关键字详解
- 基于CGAL高效生成TIN网
- 设计模式C++实现(6)——建造者模式
- 设计模式C++实现(5)——原型模式、模板方法模式
- 设计模式C++实现(4)——单例模式
- 设计模式C++实现(3)——适配器模式
- 设计模式C++实现(2)——策略模式
- 设计模式C++实现(1)——工厂模式
- OC语言3-方法和文件编译
- 数组中只出现一次的数字 -- 尝试下set,以及异或^
- STL运用的C++技术(7)——代码整合
- STL运用的C++技术(6)——函数对象
- c++中[Error] 'cin' was not declared in this scope 是什么意思
- C/C++中static关键字详解
- STL运用的C++技术(5)——重载操作符
- STL运用的C++技术(4)——重载函数
- STL运用的C++技术(3)——模板实参推断