I have a situation like this.
declare array of char*;
switch(id)
{
case 1:
add 4 words in array
case 2:
add 2 words in array
default:
add 1 word in array
}
use array here;
Is it possible to do such thing in C++.
I tried doing that but it is not working for me.
Yes. For clean, easy-to-understand, correct, exception-safe code, use
vectorandstring:Of course, you can accomplish similar results using manual dynamic allocation and cleanup of both the array and the C strings, but to do so and to ensure that the code is correct and exception-safe is more difficult and would require substantially more code.