06 2013 档案
摘要:C 自带了一个排序函数qsort, 使用时要定义一个compare方法。下面是一个例子:/* qsort example */#include <stdio.h> /* printf */#include <stdlib.h> /* qsort */int values[] = { 40, 10, 100, 90, 20, 25 };int compare (const void * a, const void * b){ return ( *(int*)a - *(int*)b );}int main (){ int n; qsort (values, 6, size
阅读全文
摘要:链接:http://blog.csdn.net/xuleicsu/article/details/919801more info:http://guoyiqi.iteye.com/blog/1626922http://www.wutianqi.com/?p=1822http://www.cnblogs.com/bigshow/archive/2009/01/03/1367661.html如何将二维数组作为函数的参数传递今天写程序的时候要用到二维数组作参数传给一个函数,我发现将二维数组作参数进行传递还不是想象得那么简单里,但是最后我也解决了遇到的问题,所以这篇文章主要介绍如何处理二维数组当作参数
阅读全文
摘要:In C, what's the difference betweenchar *s="Hello"; andchar s[]="hello";The difference here is thatchar*s ="Hello";will place Hello in the read-only parts of the memory and making s a pointer to that, making any writing operation on this memory illegal. While doing:
阅读全文
摘要:strcpy 与 strcat是两个常用的字符串处理的函数,经常可以用来给一个空的字符串赋值。example:char a[]="abcd";char b[5];strcpy(b, "");strncpy(b, a, 4);printf("b:%s\n", b);上面这段代码的输出结果为:abcd烫烫为什么在abcd之后会出现乱码呢?查了资料之后发现strcpy(strncpy)不会自动在字符串之后添加终止符。当把strncpy换成strncat之后,程序就能正常运行了,这是因为strncat会自动添加终止符,但是这要求b有足够的si
阅读全文
浙公网安备 33010602011771号