编程基础
Season_hangzhou
这个作者很懒,什么都没留下…
展开
-
windows下一键拷贝文件脚本
copy.bat copy /D/Y Z:\rootfs\root\demo.exe \\10.48.177.180\rootfs\root\原创 2012-12-24 09:36:38 · 1581 阅读 · 0 评论 -
linux c ip过滤 正则表达式 初步代码
#include #include #include #include #include int main(){ int cflags = REG_EXTENDED; regmatch_t pmatch[1]; const size_t nmatch = 1; int status, i; regex_t reg; char *pattern原创 2013-07-05 16:28:54 · 1938 阅读 · 0 评论 -
三个例子让你透彻理解const (C/C++)
三个例子让你透彻理解const (C/C++)一、指向 const 对象的指针指向 const 对象的指针,指的是指针指向的内容是const的,不可修改,但指针本身是可以修改的。例1:char acConst[] = "const";const char *pcConst = acConst; *pcConst = ‘C’; /* Error,像这样修改pcConst指向内容的做法是不允许的 */原创 2013-09-16 20:59:34 · 5493 阅读 · 1 评论 -
linux链接器 -Wl 参数的用法
注意,如果连接器通过被编译器驱动来间接引用(比如gcc), 那所有的连接器命令行选项前必须加上前缀'-Wl'(或者能被特定编译器驱动接受的其他前缀),就像下面这样: gcc -Wl,--startgroup foo.o bar.o -Wl,--endgroup 这很重要,因为否则的话,编译器驱动程序会默认丢掉这些连接选项,产生一个错误的连接.转载 2013-11-25 15:53:29 · 9090 阅读 · 0 评论 -
linux 开源项目 交叉编译选项的配置
./configure --help获取到帮助信息在shell下输入下面的命令,能配置交叉编译选项,红色的表示交叉编译时必须配置:CC=arm-hisiv200-linux-gcc CXX=arm-hisiv200-linux-g++ ./configure--host=i686-pc-linux-gnu --target=arm-hisiv200-linux --wi原创 2013-12-31 14:49:09 · 1600 阅读 · 0 评论 -
对于位域在结构体中的比特序
对于小端系统来说,用结构体表示位域,其排在前面的占字节的低端,排在后面的占字节序的低端。例:对应结构体为:typedef struct tagRTP_HEAD_S{ UINT8 cc:4; /* CSRC count */ UINT8 x:1; /* header extension flag */ UINT8 p:1; /* paddi原创 2014-03-03 12:20:19 · 1654 阅读 · 0 评论 -
pack(1)的使用
在网络编程中,一字节对齐是必须的事,原创 2014-04-14 15:37:34 · 2251 阅读 · 0 评论 -
在32位系统中使用fseek和lseek或fwrite、write写大文件时,最大只能写2G左右的解决办法
我在32位linux系统下,用fwrite写文件时,发现zui原创 2014-07-07 15:29:32 · 6240 阅读 · 0 评论 -
整理华为C/C++编码规范
目 录1 排版2 注释3 标识符命名4 可读性5 变量、结构6 函数、过程7 可测性8 程序效率9 质量保证10 代码编辑、编译、审查11 代码测试、维护12 宏1 排版1-1:程序块要采用缩进风格编写,缩进的空格数为4个原创 2015-01-07 16:18:24 · 5277 阅读 · 0 评论 -
C语言中的常用的几种系统时间结构体类型
在C语言涉及中经常需要定时触发事件,涉及到获取系统时间,其结构体类型有多种。Unix/Linux系统下有以下几种时间结构:1、time_t 类型:长整型,一般用来表示从1970-01-01 00:00:00时以来的秒数,精确度:秒;由函数time()获取; 该类型定义在头文件 /usr/include/sys/time.h 中: #define _TIME_T转载 2013-04-02 13:42:56 · 2262 阅读 · 0 评论 -
C语言 运算符优先级 详细列表
优先级运算符名称或含义使用形式结合方向说明1[]数组下标数组名[常量表达式]左到右 ()圆括号(表达式)/函数名(形参表) .转载 2013-02-21 16:43:42 · 481 阅读 · 0 评论 -
debug 打印 开关 设计(for c || C++)
一、头文件:#define debug 1 #if debug#define dbg_print(format,args...)\ do\ {\ printf("[%s][%d]"format,__FUNCTION__, __LINE__,## args);\ }while(0)#else#define dbg_print原创 2012-12-17 10:13:42 · 2132 阅读 · 0 评论 -
Linux系统获取主机网关IP 代码(C/C++)
#include //for in_addr#include //for rtnetlink#include //for IF_NAMESIZ, route_info#include #include //for malloc(), free()#include //for strstr(), memset()#include using namesp转载 2012-12-27 13:53:14 · 1505 阅读 · 0 评论 -
编程常用的C文件注释以及函数注释
一、文件头注释:/********************************************************************************* *Copyright(C),2010-2011,Your Company *FileName: // 文件名 *Author: //作者 *Version: //版本 *Date原创 2012-10-22 13:34:30 · 2831 阅读 · 0 评论 -
处理 /usr/bin/ld: cannot find -lc等编译问题
用g++编译C++程序时显示出:/usr/lib/ld: cannot find -lc/usr/lib/ld: cannot find -lgcc_s/usr/lib/ld: cannot find -lm/usr/lib/ld: cannot find -lgcc_s的错误。在网上看了很多中关于/usr/lib/ld: cannot find -lXXX的解法,但是大同小异转载 2013-01-05 15:50:26 · 16314 阅读 · 0 评论 -
交叉编译时报错:/usr/bin/ld: cannot find -lc
我用的是RHEL6.3的系统,在交叉编译时报错:/usr/bin/ld: cannot find -lc。网上搜了说要装glibc,但我的系统本身就带的,又装了一边,还是报这个错误。我仔细排查,发现当有gcc -static ×××时报错,无static时正常。找了下,原来RHEL的安装盘里根本没有glibc-static安装包。这个折腾了我好久啊,太坑了!!!原创 2013-01-05 17:00:26 · 4415 阅读 · 0 评论 -
open中O_EXCL选项的介绍与分析
open的man中的介绍:O_EXCL Ensure that this call creates the file: if this flag is specified in conjunction with O_CREAT, and pathname already exists, then open() will fail. The behavio原创 2013-01-06 12:29:08 · 3781 阅读 · 0 评论 -
打印非字符串数组函数
int PrintArray(unsigned char *pStr, int len){ int i = 0; printf("print array:\n"); for(i = 0; i { printf("%02x ", pStr[i]); i++; if ((i % 15) == 0)原创 2012-12-22 16:28:10 · 476 阅读 · 0 评论 -
double型(双精度型)的打印(printf) 和scanf
double型,printf()用%f输出,而scanf用%lf来接受输入。 格式printfscanf%c int char * %d, %i int int * %o, %u, %x unsigned int u转载 2013-03-04 14:02:36 · 52263 阅读 · 0 评论 -
标准C的.h文件的模板
#ifndef __COMMON_H__#define __COMMON_H__ #ifdef _cplusplusextern "C"{#endif /*********************** 宏定义区 ***********************/ /*********************** enum 区 ********原创 2012-10-22 14:39:33 · 1170 阅读 · 0 评论 -
程序运行产生SIGABRT信号的原因
目前我所知的程序运行产生SIGABRT信号的原因有三个,若还有其他情况,敬请网友留言。(注:SIGABRT信号即signal 6的信号)一、多次free导致的SIGABRT#include "stdlib.h"#include "string.h"#include "stdio.hint main(){ void *pc = malloc(1024);原创 2017-02-08 14:53:31 · 42322 阅读 · 1 评论