摘要: strtok简介 下面的说明摘自于最新的Linux内核2.6.29,说明了strtok()这个函数已经不再使用,由速度更快的strsep()代替。 函数说明 char *strtok(char s[], const char *delim); strtok()用来将字符串分割成一个个片段。参数s指向欲分割的字符串,参数delim则为分割字符串中包含的所有字符。当str... 阅读全文
posted @ 2013-06-02 23:05 浪里飞 阅读(764) 评论(0) 推荐(0) 编辑
摘要: strtol简介 long int strtol(const char *nptr, char **endptr, int base) strtol()会将nptr指向的字符串,根据参数base,按权转化为long int, 然后返回这个值。 参数base的范围为2~36,和0;它决定了字符串以被转换为整数的权值。 可以被转换的合法字符依据base而定,举例来说,当b... 阅读全文
posted @ 2013-06-02 21:06 浪里飞 阅读(440) 评论(0) 推荐(0) 编辑
摘要: 判断字符串是否为ip 法1: #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include <errno.h> int if_a_string_is_a_valid_ipv4_address(const ch... 阅读全文
posted @ 2013-06-02 20:36 浪里飞 阅读(494) 评论(0) 推荐(0) 编辑
摘要: Css让文字自适应Table宽度[转] .ctl{ table-layout:fixed } .ctl td{text-overflow:ellipsis;overflow:hidden;white-space: nowrap;padding:2px} 关键样式: table-layout:fixed 固定布局的算法,则表格被呈递的默认宽度为 100% (... 阅读全文
posted @ 2013-06-02 20:10 浪里飞 阅读(6207) 评论(0) 推荐(0) 编辑
摘要: #define offsetof(s,m) (size_t)&reinterpret_cast<const volatile char&>((((s *)0)->m))该宏用于求结构体中一个成员在该结构体中的偏移量。第一个参数是结构体的名字,第二个参数是结构体成员的名字。该宏返回结构体structName s中成员memberName(m)的偏移量。偏移量是size_t类型的。offsetof returns the offset in bytes of the specified member from the beginning of its parent 阅读全文
posted @ 2013-06-02 16:25 浪里飞 阅读(561) 评论(0) 推荐(0) 编辑
摘要: typedef long time_t; 表达时间(秒数)size_t是标准C库中定义的,32位中为unsigned int,在64位系统中为 long unsigned int,用于指明数组长度或下标,它必须是一个正数,设计size_t就是为了适应多个平台,其引入增强了程序在不同平台上的可移植性。ptrdiff_t是long int类型,用于存放同一数组中两个指针之间的差距,它可以使负数,使用ptrdiff_t来得到独立于平台的地址差值.size_type是unsigned类型,表示容器中元素长度或者下标,vector<int>::size_type i;difference_t 阅读全文
posted @ 2013-06-02 11:56 浪里飞 阅读(1251) 评论(0) 推荐(0) 编辑
摘要: ptrdiff_t简介 ptrdiff_t是C/C++标准库中定义的一个与机器相关的数据类型。ptrdiff_t类型变量通常用来保存两个指针减法操作的结果。ptrdiff_t定义在stddef.h(cstddef)这个文件内。ptrdiff_t通常被定义为long int类型。 ptrdiff_t定义在C99标准中。 #include <stdio.h> #inclu... 阅读全文
posted @ 2013-06-02 11:30 浪里飞 阅读(828) 评论(0) 推荐(0) 编辑
摘要: 关于TIME_WAIT可能引发的网络问题 统计? shell> netstat -nt | awk '/^tcp/ {++state[$NF]} END {for(key in state) print key,"\t",state[key]}' 如何减少? 网络上已经有不少相关的介绍,大多是建议: shell> sysctl net.ipv4.tcp_tw_r... 阅读全文
posted @ 2013-06-02 11:15 浪里飞 阅读(669) 评论(0) 推荐(0) 编辑
摘要: TCP Timestamp选项 Description Protocol suite: TCP/IP. Protocol type: Transport layer protocol. Option length: 10 bytes. The TCP Timestamp option obsoletes the TCP Echo request and Ech... 阅读全文
posted @ 2013-06-02 11:08 浪里飞 阅读(3110) 评论(0) 推荐(0) 编辑