![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
c++
jiajiahebangbang
这个作者很懒,什么都没留下…
展开
-
c++分割字符串,strtok与strtok_r的使用记录
strtok的使用写在最开头,strtok是线程不安全的,在使用时一定要考虑到这点。strtok函数使用一个静态变量存储中间值,不要在多线程编程下使用这个函数,不然一定出错。这个函数头文件是 string.h,定义为:char * strtok(char *s, const char *delim)char* s为源字符串,即要被切分的字符串,char * delim为分隔符集合,意味着可以放入多个原创 2017-07-26 22:01:34 · 2335 阅读 · 0 评论 -
在C++类中使用pthread实现多线程
现在pthread的api已经相当完善,使用其实现多线程难度不大,但是值得注意的一点是当想在类中使用pthread,调用pthread_create函数时,传入的运行函数,也就是下面这个原型的第三个参数void * ( * start_routine) (void *),如果是类的成员函数,必须是静态函数,否则将编译不通过,编译器会出一个这种错误。因为类的this指针在多线程下操作的问题,非静态的成原创 2017-07-28 21:11:06 · 9136 阅读 · 1 评论