摘要: 1、字符数组不会自动添加’\0’,字符串会自动添’\0’;所以sizeof(c1)==3,sizeof(c4)==4;strlen(c1)==不可预知,strlen(c3)==3;2、sizeof结果是变量所占内存大小;strlen结果是遇到的第一个’\0’之前的字符数。#include <stdio.h>int main(void){ char c1[] = {'a', 'b', 'c'}; char c2[] = {'a', 'b', 'c', '\0'}; char 阅读全文
posted @ 2012-12-09 22:00 helloweworld 阅读(709) 评论(0) 推荐(0) 编辑
摘要: qsort(数组名,元素个数,元素类型大小,cmp);#include <stdio.h>#include <stdlib.h>int cmp(const void *a, const void *b){ return (*(int *)a - *(int *)b); //从小到大。// return (*(int *)b - *(int *)a); //从大到小。}int main(vo... 阅读全文
posted @ 2012-12-09 20:53 helloweworld 阅读(171) 评论(0) 推荐(0) 编辑