C
raesnow
这个作者很懒,什么都没留下…
展开
-
Linux系统C语言--编译调试
1)gcc GNU Compiler Collection分为四个阶段:a)预处理Pre-Processing:gcc -E test.c -o test.ib)编译Compiling: gcc -S test.i -o test.s 汇编语言文件c)汇编Assembling: gcc -c test.s -o test.o 二原创 2012-08-30 14:40:33 · 575 阅读 · 0 评论 -
C语言--库
动态库和静态库:在程序中使用动态库和静态库时,它们的载入顺序是不一样的。静态库的代码在编译时就拷贝到应用程序中,因此当多个应用程序使用同一个静态库时,内存中会有多个副本。这样的优点是节省编译时间。动态库是在程序开始运行后调用库函数时才被载入,被调函数在内存中只有一个副本,并且程序可以在程序运行期间释放动态库所占用的内存,腾出空间供其他程序使用。原创 2012-09-19 17:28:13 · 541 阅读 · 0 评论 -
C语言--rand
#include #include #define NUMBER XXXsrand(time(NULL)):int randNumber = rand() % NUMBER; 使用rand函数产生随机数之前,需要进行随机数种子设置。其中%NUMBER是为了生成一定范围内的随机数。srand函数是随机数发生器的初始化函数。 原型:void srand(uns原创 2012-09-11 15:43:29 · 620 阅读 · 0 评论 -
C语言--简单小代码1
说明:以下内容摘自《C程序设计语言》,自己编写等(《The C Programming Language》 Brian W.Kernighan,Dennis M.Ritchie)1)for(p = head; p != NULL; p = q){ q = p->next; free(p); } 2)Union原创 2012-08-30 15:20:59 · 976 阅读 · 0 评论 -
排序算法1
1)插入排序说明:最坏情况运行时间为O(n*n),原地排序(sorted in place),稳定的其内部循环紧密,对小规模输入来说是快速的void insertion_sort(int a[], int length){ int i, j, key; for(j = 1; j < length; j++) { key = a[j];原创 2012-08-30 15:09:25 · 288 阅读 · 0 评论 -
算法--基本问题小记1
说明:以下摘自《程序员面试宝典(第二版)》,《Linux C编程实战》,自己和同学的面试体验等还有参照博客:http://zhedahht.blog.163.com/1)float变量x与0比较if((x >= -0.00001) && ( x 说明:不能用==或!= 0.0 2)随机数生成: 头文件stdlib.h, time.hsrand(time(NU原创 2012-09-04 14:57:08 · 342 阅读 · 0 评论 -
C语言--static
1.请解释关键字static,并说明至少两种static的用途。 答:静态变量(以static作为修饰符的变量)存储在内存的静态存储区,静态存储区在程序的整个运行期间都存在。未经初始化的静态变量会被程序自动初始化为0(自动变量的值是任意的,除非被显示初始化)。静态变量分为两种:全局静态变量和局部静态变量。全局静态变量是在所有函数之外定义的静态变量,局部静态变量是在某个函数内部定义的变量。全原创 2012-09-04 14:58:15 · 289 阅读 · 0 评论 -
C语言--memmove和memcpy比较
memmove 原型:void *memmove( void* dest, const void* src, size_tcount );用法:#include 或#include 功能:由src所指内存区域复制count个字节到dest所指内存区域。说明:src和dest所指内存区域可以重叠,但复制后dest内容会被更改。函数返回指向dest的指针。转载 2012-09-04 14:56:24 · 422 阅读 · 0 评论 -
算法--小代码记录1
说明:以下代码摘自《程序员面试宝典(第二版)》,自己编写,同学编写等,从网上转载的会标注具体转载地址。1)递归反序输出字符串void reverse(char *p){ if(*p == '\0') return; reverse(p + 1); putchar(*p); return;} 2)原创 2012-09-04 14:56:49 · 296 阅读 · 0 评论 -
算法--两个数大小比较,不用分支判断
说明:摘自《程序员面试宝典(第二版)》,以及同学讨论 原题:There are two in variables: a and b, don't use "if", "?:", "switch" or other judgement statements, find out the biggest one of the two numbers.(有两个变量a和b,不原创 2012-09-04 14:56:35 · 2222 阅读 · 1 评论 -
Linux系统C语言--基本知识小记1
1)使用UNIX系统调用的接口,可以提升代码效率 syscall.hread, write(int fd, char *buf, int n)open(char *name, int flags, int perms)creat(name, perms)close(fd)unlink(name) = removelseek(int fd, lo原创 2012-09-04 14:53:12 · 290 阅读 · 0 评论 -
C语言--文件操作函数
1)fopen(filename, mode)mode: r w a r+ w+ a+在linux下加不加b都是一样的 fclose(filename) 示例:FILE *fp;if((fp = fopen("file", "r")) == NULL) { fprintf(stderr, "Error:……, %s \原创 2012-08-30 15:16:23 · 776 阅读 · 0 评论 -
C语言--qsort函数
C程序使用标准库函数qsort排序整数文件 #include #include #include #include #define MAX 10 int int_cmp(const void *a, const void *b){ return *(int *)a - *(int *)b;}int main(){原创 2012-08-30 15:11:56 · 602 阅读 · 0 评论 -
Linux系统C语言--makefile1
make: Makefile或makefile文件make -f othernamemake --file=othername 这两个命令使用其他名字的文件make makefile写法:target: components[;rule]rule说明:target依赖于components,其生成规则定义于rule。component原创 2012-08-30 14:42:43 · 555 阅读 · 0 评论 -
C语言--基本知识小记1
1)#include "my_tool.h" 在main.c中和mytool.c中my_tool.h中列出mytool.c中的函数接口 2)#includefprintf(stderr, "%s", strerror(errno)); 3)\a 响铃提示'\0'表示值为0的字符,即NULL 4)0.0可以表示为.0 5)short类型 16原创 2012-08-30 15:22:40 · 616 阅读 · 0 评论