随笔分类 - C Primer Plus
C Primer Plus
摘要:1、共享库的概念 2、创建共享库命令 具体加不加 fpci 这个要看平台支持吧支持;具体详情可以查阅 shared的相关参数文档 这里有一个-fPIC参数PIC就是position independent codePIC使.so文件的代码段变为真正意义上的共享如果不加-fPIC,则加载.so文件的代
阅读全文
摘要:(一)静态库就是把一些*.o的文件集合起来;以*.a结尾打包;做成的lib库文件;专门放到lib目录下 静态库的制作: 1.制作*.a文件 把之前src/mymath.c 的源文件 编译成单独的o文件 gcc -o obj/mymath.o -Iinclude -c src/mymath.cgcc
阅读全文
摘要:#include #include void text_to_bin(char *argv[]); void bin_to_text(); typedef struct { int xh; char name[20]; int age; }Student; int main(int a,char *argv[]){ if(a!=4){ printf("参数不够!\n");...
阅读全文
摘要:#include #include //功能: 合并2个源文件的内容,到一个新的文件中 int main(int a,char *argv[]){ if(a!=4){ printf("请输入3个文件路径:%s\n", argv[0]); exit(1); } FILE *fp1,*fp2,*fp3; fp1 = fopen(argv[1],"r"); if(fp1==NUL...
阅读全文
摘要:#include #include #define IS_WHITE_SPACE(c) ((c)==' '||(c)=='\t'||(c)=='\n') ? 1:0 //统计文件:内容大小字节 和函数 int main(int a,char *argv[]){ if(a!=2){ printf("useage:%s source!\n", argv[0]); exit(1); ...
阅读全文
摘要:#include #include //文件的内容复制 int main(int a,char *argv[]){ if(a!=3){ printf("useage:%s source!\n", argv[0]); exit(1); } FILE *fp1, *fp2; fp1 = fopen(argv[1],"r"); if(fp1==NULL){ prin...
阅读全文
摘要:以CentOS为例,安装后是没有C语言和C++编译环境的,需要手动安装,最简单的是用yum的方式安装,过程如下: 1、安装gcc 询问是否,按y键回车即可,或者 不用确定全部就安装好了。 2、安装g++ 安装完毕。 只在CenOS 7.2下测试正常
阅读全文
摘要:#include #include "head.h" #define TRUE 1 #define FALSE 0 #if defined (TRUE) && !defined (FALSE) #error YOU NEED TO DEFINE FALSE... #elif defined (FALSE) && !defined (TRUE) #error you need to de...
阅读全文
摘要:#include #include void out(int *p, int n){ int i; for(i=0;i<n;i++){ printf("%d ", *(p+i)); } printf("\n-------------------\n"); } int main(void){ printf("请输入要申请几块整型为4字节大小的块内存:"); int n; s...
阅读全文
摘要:#include #include void out(int *p, int n){ int i; for(i=0;i<n;i++){ printf("%d ", *(p+i)); } printf("\n-------------------\n"); } pr...
阅读全文
摘要:1.首先设置开关 设置 core文件的大小为1000K存放数据 [oracle@xweb1 clession]$ ulimit -c0[oracle@xweb1 clession]$ ulimit -c 1000 2. 编译-g调试程序如下 gcc -g -o bin/gdb_core src/gd
阅读全文
摘要:1、下载GDB7.10.1安装包 2、解压 3、创建安装目录 4、配置安装 在刚才解压的目录文件内/opt/gdb-7.10.1 这个目录下;执行 5、编译 6、安装
阅读全文
摘要:#include #include int main(){ //字符数组的使用 char str[] = {'z','b','c','\0'}; //字符数组 printf("str地址:%p str[0]=%c str[0]地址:%p \n",str,str[0],&str[0]); printf("str地址:%p str[1]=%c str[1]地址:%p \n",str...
阅读全文
摘要:#include #include int main(){ char str[][30] = {"zhangsan","lisi","wangwu"}; char (*p)[30] = str; //定义行指针 printf("%p %p %p 行数:%d 列数:%d\n",str, &str[0], &str[0][0], sizeof(str)/sizeof(str[0]),siz...
阅读全文
摘要:#include #include int main(){ int a = 100; void *p = &a; printf("a:%d address:%p\n",*(int*)p, &a); //unsigned int *pt = (unsigned int*)0xbfa70ee8; int *pt = (int*)malloc(sizeof(int)); *pt = 2...
阅读全文
摘要:#include int main(void){ void *p; int a = 14322; char c ='A'; p = &a; //p = &c; //强制类型转换(int*)p 把变量指针p强制转换成指向int类型的指针 printf("a=%d\n",*(int*...
阅读全文
摘要:共用体:共享同一个内存;一旦a使用了b就被弃用 b使用a就被弃用!
阅读全文
摘要:#include #include struct tells;//声明结构体 struct info { char *infos; }; typedef struct Books { char *name; int page; struct info *pinfo; struct tells *tel; }BK; struct tells{ char *age; }; void ...
阅读全文
摘要:int *p = (int *)malloc(sizeof(int)) malloc函数会返回开辟空间的首地址,加(int *)的目的是让计算机知道,如何去划分这个开辟的空间, 因为char、int 、long这些类型的字节大小是不一样的,我们知道了首地址, 还要知道是以几个字节为单元。 所以,这句
阅读全文
摘要:#include #include struct Books { char title[50]; //char author[100]; //int book_id; }; int main(){ struct Books b1; strcpy(b1.title,"C语言"); struct Books *p1; p1 = &b1; strcpy(p1->title,"Ja...
阅读全文
浙公网安备 33010602011771号