S
silverburgh.meryl
In my code, I have an array of char* pointer which is populated
statically:
void function1() {
char *ppsz_argv2[] = { "abc" ,
"def",
"dummy"};
//...
}
But how can I populated it dynamically?
void function1(string& str1, string& str2, string& str3) {
char* ppsz_arg2[] = new char[3]; // how can I allocate memory for the
array of char* here?
ppsz_arg2[0] = str1.c_str();
ppsz_arg2[1] = str2.c_str();
ppsz_arg2[2] = str3.c_str();
Thank you for any help.
statically:
void function1() {
char *ppsz_argv2[] = { "abc" ,
"def",
"dummy"};
//...
}
But how can I populated it dynamically?
void function1(string& str1, string& str2, string& str3) {
char* ppsz_arg2[] = new char[3]; // how can I allocate memory for the
array of char* here?
ppsz_arg2[0] = str1.c_str();
ppsz_arg2[1] = str2.c_str();
ppsz_arg2[2] = str3.c_str();
Thank you for any help.