Hi,
I hope someone can help. Code with comments explaining the problem is shown below.
char const char_set1[42] = {'A','B','C','D','E','F','G','H', 'I','J','K','L','M','N','O','P', 'Q','R','S','T','U','V','W','X', 'Y','Z','.','-','%','/',':','0', '1','2','3','4','5','6','7','8','9',' '}; [I then wish to declare a constant pointer to the array] [The following declaration compiles:] char const* char_set_arrayA = char_set1; [But the following declaration fails:] char const* char_set_arrayB[]={char_set1};
Eventually I need to pass a series of character set arrays into this declaration but I cannot get it to compile with one array element (char_set1).
I would be grateful for any advice as to why
char const* char_set_arrayB[]={char_set1};
is not accepted by the compiler. The compiler reports
"error #28: expression must have a constant value"
Is the const declaration incorrect?
Thanks
John McLane
One thing to think about here: Is it the value of the pointer that is constant, or is it the data the pointer points to that may not be changed? This is controlled by the location of the const keyword in the declaration.