上一页 1 ··· 29 30 31 32 33 34 35 36 37 ··· 48 下一页
摘要: 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) 编辑
摘要: #include <stdio.h>#include <string.h>#include <assert.h>#include <stdlib.h>int main(int argc, char* argv[]){ char dst[] = "abcdefgh"; char *src = "xyzd"; unsigned char map[32] = {'0'} ; printf("%d", s... 阅读全文
posted @ 2012-12-06 16:00 helloweworld 阅读(134) 评论(0) 推荐(0) 编辑
摘要: #include <stdio.h>#include <string.h>#include <assert.h>#include <stdlib.h>int main(int argc, char* argv[]){ char dst[] = "abcxdeyf"; char *src = "afbecd"; printf("%d", strspn(dst, src)); return 0;}输出... 阅读全文
posted @ 2012-12-06 15:47 helloweworld 阅读(302) 评论(0) 推荐(0) 编辑
摘要: /****char *strstr(string1, string2) - search for string2 in string1**Purpose:* finds the first occurrence of string2 in string1**Entry:* char *string1 - string to search in* char *st... 阅读全文
posted @ 2012-12-06 13:02 helloweworld 阅读(755) 评论(0) 推荐(0) 编辑
摘要: ;***;char *strrchr(string, ch) - find last occurrence of ch in string;;Purpose:; Finds the last occurrence of ch in string. The terminating; null character is used as part of the search.;... 阅读全文
posted @ 2012-12-05 20:23 helloweworld 阅读(514) 评论(0) 推荐(0) 编辑
摘要: ;***;char *strchr(string, chr) - search a string for a character;;Purpose:; Searches a string for a given character, which may be the; null character '\0'.;; Algorithm:; char *... 阅读全文
posted @ 2012-12-05 20:15 helloweworld 阅读(291) 评论(0) 推荐(0) 编辑
摘要: ;***;int strncmp(first, last, count) - compare first count chars of strings;;Purpose:; Compares two strings for lexical order. The comparison stops; after: (1) a difference between the st... 阅读全文
posted @ 2012-12-05 20:08 helloweworld 阅读(477) 评论(0) 推荐(0) 编辑
摘要: ;***;strcmp - compare two strings, returning less than, equal to, or greater than;;Purpose:; Compares two string, determining their lexical order. Unsigned; comparison is used.;; A... 阅读全文
posted @ 2012-12-05 20:01 helloweworld 阅读(188) 评论(0) 推荐(0) 编辑
摘要: #include <stdio.h>#include <string.h>#include <assert.h>#include <stdlib.h>char *mystrcat (char * dst, const char * src){ char * cp = dst; while( *cp ) /* 不写成while(*cp++)的原因是cp可能为'\0'*/ ++cp; ... 阅读全文
posted @ 2012-12-05 19:22 helloweworld 阅读(166) 评论(0) 推荐(0) 编辑
上一页 1 ··· 29 30 31 32 33 34 35 36 37 ··· 48 下一页