i just want to copy array of string to dynamical array(using new operator) without using string.h of c++ how can i copying the array?
enter code here
const int LEN=3;
int n=15;
char*s1 ;
char *s[LEN]={"music","disc","soft"};
char (*str)[LEN]=new char[n][LEN]; //i want to copy s to this array
i try to do something like this
for(int i=0; i<LEN ;i++){
strcpy(str[i],s[i]);
}
for(int i=0; i<LEN ;i++)
cout<<str[i]<<endl;
but it printing all the array in one Sequence, i think a problem with NULL terminator i don't no how to deal with
strcpy(). Andnew char[n][LEN];is wrong.const, unused variables1, and obsolete comment...char*in C++, please. It just hurts, and 99% of the time, properstd::stringis what you want. Also, please usestd::vector(or maybestd::array), even if it means typing a little more.