标签:style blog http io color ar os sp for
1 #include <iostream> 2 using namespace std; 3 4 void to_lower(char* s) 5 { 6 while(*s!=‘\0‘) 7 { 8 if(*s>=‘A‘&&*s<=‘Z‘) 9 *s+=32; 10 s++; 11 } 12 } 13 14 char* strdup1(const char*s) 15 { 16 char *p=new char[]; 17 cout<<sizeof(s)<<endl; //////////注意 18 int i; 19 for(i=0;s[i]!=‘\0‘;i++) 20 { 21 p[i]=s[i]; 22 } 23 p[i]=‘\0‘; 24 return p; 25 } 26 27 char* findx(const char*s,const char*x) 28 { 29 int i=0; 30 while(*s!=‘\0‘) 31 { 32 while(*(s+i)==*(x+i)&&*(x+i)!=‘\0‘) 33 { 34 i++; 35 } 36 if(*(x+i)==‘\0‘) 37 return (char*)s; 38 else 39 i=0; 40 s++; 41 } 42 return NULL; 43 } 44 45 int main() 46 { 47 //char c[]="D"; 48 //cout<<sizeof(&c)<<endl; //////////注意 49 //char *p=strdup1(c); 50 // cout<<p<<endl; 51 char c1[]="fgasdfghj"; 52 char c2[]="fgh"; 53 cout<<findx(c1,c2); 54 while(1); 55 return 0; 56 57 }
标签:style blog http io color ar os sp for
原文地址:http://www.cnblogs.com/yueba/p/4088449.html