c 函数介绍
文章平均质量分 61
忘不烦
自信勇敢喜欢运动喜欢接受挑战
展开
-
strftime和strptime使用
这两个函数都是时间日期的格式控制函数,在功能上看起来正好相反。strftime将一个tm结构格式化为一个字符串,strptime则是将一个字符串格式化为一个tm结构。strftime函数原型:size_t strftime(char *s,size_t maxsize,char *format,const struct tm *timeptr)strftime函数对timept转载 2014-03-09 10:49:37 · 2839 阅读 · 0 评论 -
snprintf() 替代 sprintf()
关于sprintf和snprintf的正确使用。考虑以下有缺陷的例子:void f(const char *p){ char buf[11]={0}; sprintf(buf,"%10s",p); // very dangerous printf("%sn",buf);}不要让格式标记“%10s”误导你。如果p的长度大于10个字符,那么sp转载 2014-03-09 13:33:13 · 4866 阅读 · 1 评论 -
网络字节转换函数 htons(), htonl(), ntohs(), ntohl()
将多字节整数类型的数据,从主机的字节顺序转化为网络字节顺序原型:#include uint32_t htonl(uint32_t hostlong);uint16_t htons(uint16_t hostshort);uint32_t ntohl(uint32_t netlong);uint16_t ntohs(uint16_t netshort);转载 2014-03-09 13:41:45 · 3522 阅读 · 0 评论 -
inet_pton函数 和inet_ntop函数
inet_pton函数:将点分十进制串转换成网络字节序二进制值,此函数对IPv4地址和IPv6地址都能处理。int inet_pton(int family,const char * strptr,void * addrptr); //返回:1---成功 0---输入不是有效的表达格式 -1---失败 第一个参数可以是AF_INET或AF_INET6:第二个参数是一个指向点分十进制原创 2014-03-09 11:53:24 · 12723 阅读 · 1 评论 -
linux常用C头文件
linux常用C头文件linux常用C头文件aio.h 异步I/Oassert.h 验证程序断言 complex 复数类complex.h 复数处理cpio.h cpio归档值 ctype.h 字符类型 dirent.h 目录项,opendir(),closedir(),readdir(),readdir64()dlfcn.h转载 2014-03-24 16:11:09 · 623 阅读 · 0 评论