A
Andrea Taverna (Tavs)
Subject: Initialization of a const matrix implemented as pointer-to-pointer
Hello everyone.
I've got the following matrix definition in a source file
static const char **a;
I need it to be initialized as an array of strings, something like
static const char **a = {"Alpha", "Beta", Charlie"};
I know the number of strings and their maximum length, but I can't use a
stack-allocated matrix for compatibility reasons with another piece of
code, which simply defines a
char** strings
to which the matrix has to be assigned to.
I thought I could write a static const declaration for each string
static const str1[MAX_LENGTH] ="Alpha"
and then declare the matrix as
static const char* a[NUM_OF_STRINGS] = {str1,str2,...}
would it be correct?
thanks for your attention
AT
Hello everyone.
I've got the following matrix definition in a source file
static const char **a;
I need it to be initialized as an array of strings, something like
static const char **a = {"Alpha", "Beta", Charlie"};
I know the number of strings and their maximum length, but I can't use a
stack-allocated matrix for compatibility reasons with another piece of
code, which simply defines a
char** strings
to which the matrix has to be assigned to.
I thought I could write a static const declaration for each string
static const str1[MAX_LENGTH] ="Alpha"
and then declare the matrix as
static const char* a[NUM_OF_STRINGS] = {str1,str2,...}
would it be correct?
thanks for your attention
AT