0
点赞
收藏
分享

微信扫一扫

一些可能常用的工具函数

新鲜小饼干 2022-03-14 阅读 144
tv

一些可能常用的工具函数

  • 返回当前的微秒数, 1s = 1000ms,1ms = 1000us
 
  1. // 返回当前时间的微秒

  2. long GetCurrentTime(){

  3. timeval tv;

  4. gettimeofday(&tv,nullptr);

  5. return tv.tv_sec * 1000000 + tv.tv_usec;

  6. }

  • 将文件内容读到 string 里面
 
  1. ifstream in("test.txt",ios::in);

  2. istreambuf_iterator<char> beg(in), end;

  3. string content(beg, end);

  4. in.close();

  5. printf("content : %s\n",content.c_str());

举报

相关推荐

0 条评论