摘要: 1 #include <stdio.h> 2 3 void permutation(char s[], int b, int e) 4 { 5 if( (0 <= b) && (b <= e) ) 6 { 7 if( b == e ) 8 { 9 printf("%s\n", s);10 }11 else12 {13 int i = 0;14 15 for(i=b; i... 阅读全文
posted @ 2013-01-31 10:57 海 哥 阅读(321) 评论(0) 推荐(0) 编辑
摘要: void UpperCase( char str[] ) // 将 str 中的小写字母转换成大写字母 { int i; for(i=0; i<sizeof(str)/sizeof(str[0]); i++ ) { if( "a"<=str[i] && str[i]<="z" ) { str[i] -= ("a" - "A" ); } }} 分析结果:这个程序有以下几个大的问题1.函数参数中的数组一定会退化为指针,所以sizeof(str)/sizeof(str[0])的值只有4, 阅读全文
posted @ 2013-01-31 10:56 海 哥 阅读(163) 评论(0) 推荐(0) 编辑
摘要: 1 #include<stdio.h> 2 3 int main(int argc, char *argv[]) 4 { 5 char p1[] = "abcd"; 6 char* p2 = "abcd"; 7 8 p1[0] = 'a'; 9 p2[0] = 'a';10 11 return 0;12 } 为什么程序崩溃了?分析结果p1是一个数组,这个数组使用字符串"abcd"初始化,所以p1这个数组的大小为5,存储在栈上p2是一个指针,指向一个只读存储区中的字符串"abcd&q 阅读全文
posted @ 2013-01-31 10:52 海 哥 阅读(280) 评论(1) 推荐(0) 编辑
摘要: 字符串查找 阅读全文
posted @ 2013-01-31 10:46 海 哥 阅读(339) 评论(0) 推荐(0) 编辑