0

I want to declare of array of pointers to arrays of char *.

When i compile the code, i got warnings:

warning: initialization of ‘const char *’ from incompatible pointer type ‘const char **’ [-Wincompatible-pointer-types]

This code works, but i know i do something wrong and i should not have any warnings by C compiler. How to declare it right?

const char *S6_ARR[] = {
        "here",
        "we"
};

const char *S7_ARR[] = {
        "go",
        "again"
};

const char *SHEET_HEADER_ARR[] = {
        S6_ARR,
        S7_ARR
};

int main()
{
    ...
}
1
  • Learn about typedef. It makes your code much more readable. Take inspiration from existing open source code, e.g. GTK Commented Dec 22, 2020 at 3:40

1 Answer 1

2

The warning is telling you that you are trying to put elements of type const char ** into an array of type const char *. So change the array type to match what you're putting into it:

const char **SHEET_HEADER_ARR[] = {
        S6_ARR,
        S7_ARR
};
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.