How to create a static const array from const char *

I tried the following line:
static const const char* values[];
But I get the following warning about warning VC ++ C4114: a qualifier of the same type is used more than once.
What is the correct declaration?

Editing:
The goal is to create an immutable array of strings c

+6
source share
2 answers

You wrote const const instead of static const char* const values[]; (where you define the pointer and base values ​​as const )

In addition, you need to initialize it:

static const char* const values[] = {"string one", "string two"};

+13
source

Try

 static const char* const values[]; 

The idea is to put two const on either side of * : the left belongs to char (constant character), the right belongs to char* (constant pointer to character)

+4
source

Source: https://habr.com/ru/post/917893/


All Articles