Example: // test.h
#define MAX 3
test.cpp
static char *movies[MAX] = {
"The Departed", "The Crow", "Hot Fuzz"};
//
Why not use Vector<char*>, or Vector<string*>, or an Array, or another data type? What benefits do i have over the other data types?
Let me preface this by saying that i'm coming from the Java world andi've been learning C for a few months.
CodePudding user response:
You will not have to directly cast the pointer to another type.. if some functions only accept the char ptr vector then you will not have any conversion to do
CodePudding user response:
What benefits do i have over the other data types?
One thing to notice if using std::vector
is that it will be initialized dynamically at runtime while the static const char*[max]
can be initialized at compile time. So it will save some(very little though) runtime.