一些可能常用的工具函数

阅读 144

2022-03-14

一些可能常用的工具函数

  • 返回当前的微秒数, 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)

0 0 举报