const char * 转换为 char *

const char * 转换为 char *, 不能使用强制类型转换,应该用strcpy,也就是另开一块内存,把字符一个个复制过去
const char *str= "test is ok!";
char *str2= new char[strlen(str)+1];
strcpy(str2,str);

posted @ 2011-08-26 11:40  hongweigg  阅读(82)  评论(0)    收藏  举报