满意答案
wustguangh 19级 2015-01-11 10:26:13
1.使用string辅助
int main() { char *char1 = "edab"; char *char2 = "dfrey"; string str1(char1); string str2(char2); string str3; str3 = str1 + str2; cout << str3 << endl; }
2.使用strcpy
int main() { char *char1 = "edab"; char *char2 = "dfrey"; char destnation[100]; strcpy(destnation,char1); cout << destnation << endl; }
3.使用strcat
/* STRCPY.C: This program uses strcpy * and strcat to build a phrase. */ #include <string.h> #include <stdio.h> void main( void ) { char string[80]; strcpy( string, "Hello world from " ); strcat( string, "strcpy " ); strcat( string, "and " ); strcat( string, "strcat!" ); printf( "String = %s ", string ); } Output String = Hello world from strcpy and strcat!