有趣的字符串copy函数
作者:互联网
1 #include <iostream> 2 #include <iomanip> 3 #include <string> 4 using namespace std; 5 double power(double x,int n); 6 char * mycopy(char *dest, const char * src) 7 { 8 if(src == NULL || dest ==NULL) 9 return NULL; 10 if(src == dest) 11 return NULL; 12 char *temp = dest; 13 cout << "src = " << src << endl; 14 while((*dest++ = *src++)!= '\0'){} 15 16 cout <<"temp = "<<temp<<endl; 17 18 return temp; 19 } 20 21 int main() 22 { 23 cout <<"hello"<<endl; 24 25 char src[10] = "wfg"; 26 char dest[10]; 27 mycopy(dest,src); 28 cout << "dest = "<< dest <<endl; 29 return 0; 30 31 }
标签:src,NULL,return,dest,char,include,字符串,有趣,copy 来源: https://www.cnblogs.com/xhu218/p/16683724.html