//=================================================== //myStrcpy.cpp //by leo //5.26.2011 //=================================================== #include <iostream> using namespace std; //--------------------------------------------------- char* myStrcpy(char* s1, const char* s2) { char* s = s1; while(*s++ = *s2++); return s1; } char* myStrcpy1(char* s1, const char* s2) { char* s = s1; while(1) { *s = *s2; /* s2++; char* tmp = s; s++; if(* tmp==0) break; */ if(*s == 0) break; s++; s2++; } return s1; } int main() { char a[50], b[50]; const char* s = "hello,leo!0123/n"; cout<<myStrcpy(a,s)<<endl; cout<<s<<endl; cout<<a<<endl; myStrcpy(b,s); cout<<b<<endl; return 0; } //=================================================== 菜鸟菜鸟~.~