随笔分类 - c&c++
摘要:字节顺序函数: 小端字节序:将低序字节存储在起始地址。(linux) 大端字节序:将高序字节存储在起始地址。(网络字节序) 举个例子:对于整数0x12345678来说,在不同的系统中存放方式如图: 正是因为网际协议采取的是大端字节序,我们在编程的时候才需要考虑网络字节许和主机字节序之间的转换。下面是四个转换函数(在某些采用大端字节序的系统里面,这四个函数被定位空宏):Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->#include <n
阅读全文
摘要:Linux多线程函数用得比较多的是下面的3个pthread_create(),pthread_exit(),pthread_join();它们都是在头文件之中。编译时需要加静态库-lpthread下面是函数的说明: pthread_create是UNIX环境创建线程函数 int pthread_create( pthread_t *restrict tidp, const pthread_attr_t *restrict_attr, void*(*start_rtn)(void*), void *restrict arg); 返回值 若成功则返回0,否则返回出错编号 返回成功时,由...
阅读全文
摘要:最近看到这么一段代码:代码1.cpp:#include <iostream>using namespace std;int a=4;int main(){ a+=a++; cout<<a<<endl; return 0;}输出结果:===============================================================代码2.cpp#include <iostream>using namespace std;int a=4;int main(){ a+=++a; cout<<a<<en
阅读全文

浙公网安备 33010602011771号