[cpp]常用程序模块
文章目录
1:char *类型的字符串数字 转化为 int类型
#include<string>
stringstream test;
char a[]="-233";
test<<a;//读取到test
int b;
test>>b;//保存到 int b中
cout<<"b="<<++b<<endl; //b=-232
2:计算做一件事情 花了多长时间 的 module
double t = (double)getTickCount();
// do something ... 需要做的事情
t = ((double)getTickCount() - t)/getTickFrequency();
cout << "Times passed in seconds: " << t << endl;
//getTickFrequency() 为计算机每秒走多少步
评论
登录后参与技术讨论,分享你的经验与见解。
登录 / 注册暂无评论