2021年5月8日

C++中volatile关键字的作用(volatile应理解为直接存取原始内存地址,英文意思为易改变的)

摘要: 一个定义为volatile的变量是说这变量可能会被意想不到地改变,这样,编译器就不会去假设这个变量的值了。精确地说就是,优化器在用到这个变量时必须每次都小心地重新读取这个变量的值,而不是使用保存在寄存器里的备份。下面是volatile变量的几个例子: 1). 并行设备的硬件寄存器(如:状态寄存器) 阅读全文

posted @ 2021-05-08 16:28 findinglei 阅读(231) 评论(0) 推荐(0)

pthread_join与pthread_detach

摘要: pthread_t pthr; pthread_create(&pthr, NULL, thread_handler, NULL); ... void* thread_handler(void* arg) { /* do something */ pthread_join(pthr, NULL); 阅读全文

posted @ 2021-05-08 15:47 findinglei 阅读(120) 评论(0) 推荐(0)

strcpy()、memcpy()、memmove()、memset()的实现

摘要: strcpy(), 字符串拷贝.char *strcpy(char *strDest, const char *strSrc){ assert((strDest!=NULL) && (strSrc !=NULL)); char *address = strDest; while( (*strDest 阅读全文

posted @ 2021-05-08 15:42 findinglei 阅读(65) 评论(0) 推荐(0)

十进制转二进制、八进制、十六进制的经典程序

摘要: #include <iostream.h>//十进制数转换成二进制数字void fun_1(int n){ if(n<2) cout<<n; if(n>=2) { fun_1(n/2); cout<<n%2; }}//十进制数字转换成八进制数字void fun_2(int n){ if(n<8) c 阅读全文

posted @ 2021-05-08 15:39 findinglei 阅读(511) 评论(0) 推荐(0)

导航