- 论坛徽章:
- 0
|
#include<iostream>
#include<assert.h>
using namespace std;
char * str_copy(char *str1,const char *str2){
assert((str1!=NULL)&&(str2!=NULL));
char *temp=str1;
while((*str1++=*str2++)!='\0');
return temp;
}
int main(){
char * p ="test123";
char * q ="test456";
char * temp=str_copy(q,p);
cout<<temp<<endl;
return 0;
}
|
|
|