c++输入字符串练习程序

时间:2014-02-27 05:49:55
【文件属性】:

文件名称:c++输入字符串练习程序

文件大小:681B

文件格式:CPP

更新时间:2014-02-27 05:49:55

输入字符串

void main() { char ch,c[10],*p=NULL,*p_d; int l=1; cout<<"Type a line,press Enter to end:\n"; do { cin.get(c,10); l+=strlen(c); p_d=new char[l]; if(p_d==NULL) { cout<<"Not enough memory from heap.\n"; return; } if(p==NULL) strcpy(p_d,c); else { strcpy(p_d,p); strcat(p_d,c); } delete [] p; p=p_d; cout<<"Total:"<


网友评论