This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Error : non-address/-constant initializer

Why below line of code is not compiling successfully?
const unsigned char *a[]={
  "Hello",
   "Hi"
};

const unsigned char *b[]={
  a[0],
   a[1]
};

Parents
  • Because i am having some same strings in different array of pointers and i have to put only one in my code and want to declare rest of string in the above manner if it is a common for rest of the set.

    This can be done, but each string must be put in a separate variable.
    By the way, since we are talking about C51 here, I noticed that you are not using the code keyword for your constant variables. This could be a mistake.

Reply
  • Because i am having some same strings in different array of pointers and i have to put only one in my code and want to declare rest of string in the above manner if it is a common for rest of the set.

    This can be done, but each string must be put in a separate variable.
    By the way, since we are talking about C51 here, I noticed that you are not using the code keyword for your constant variables. This could be a mistake.

Children