指針動態數組複製字符串並返回動態數組地址,輸出兩者的值

#include<iostream.h> char * fun(char *t,char *s) { cin.getline(s,20); int l=strlen(s); t=new char[l+1]; strcpy(t,s); return t; } int main() { char a[20],b[20]; cout<<fun(a,b)<<endl; cout<<&a; return 0
相關文章
相關標籤/搜索