Read string from MEMPROG

I need some help please.

Declared array:
const char Bet_ve[6][10] PROGMEM=
{
"text1","text2","text3 ","text4","text5 ",
};

char name[8];
name= char buffer [strlen_P(Bet_ve [text_number] ) ];
I got "Compilation error: expected primary-expression before 'char' "

Thanks.

As your topic does not relate directly to the installation or operation of the IDE it has been moved to the Programming category of the forum

Please post a small but complete sketch that illustrates your problem

While you omitted telling us exactly where said error occurred (snipperitis strikes again!), I'll wager it's in the above line. It confuses me, and I imagine the compiler is equally confused. Could you explain just what it is you thought it would do?

I dare say the line below will confuse it as well...

"name" needs an address or brackets as "buffer" has brackets.

This:

const char Bet_ve[6][10] PROGMEM = { "text1", "text2", "text3", "text4", "text5" };
char name[8];
char buffer[8];
int text_number = 3;

void setup() {
  name[text_number] = buffer[strlen_P(Bet_ve[text_number])];
}

void loop() {}

Yields this:

Sketch uses 444 bytes (1%) of program storage space. Maximum is 30720 bytes.
Global variables use 9 bytes (0%) of dynamic memory, leaving 2039 bytes for local variables. Maximum is 2048 bytes.

But this...

const char Bet_ve[6][10] PROGMEM = { "text1", "text2", "text3", "text4", "text5" };
char name[8];
char buffer[8];
int text_number = 3;

void setup() {
  name = char buffer[strlen_P(Bet_ve[text_number])];
}

void loop() {}

Yields this...

sketch_oct4a.ino:7:10: error: expected primary-expression before 'char'
   name = char buffer[strlen_P(Bet_ve[text_number])];
          ^~~~
exit status 1

Compilation error: expected primary-expression before 'char'

you can't write name = char buffer[...]. The compiler sees char where it expects an expression after =, hence "expected primary-expression before 'char'".

Note also that name is a fixed-size array of 8 elements and arrays can't be assigned to with = in C/C++ at all ➜ you need to copy the bytes into that array if you need a RAM based copy.

const char Bet_ve[6][10] PROGMEM = {
  "text1", "text2", "text3 ", "text4", "text5 ",
};

char name[10];  // big enough for the longest entry + null

void getText(uint8_t text_number) {
  strlcpy_P(name, (char*)Bet_ve[text_number], sizeof name);
}
  strlcpy_P(name, (char*)Bet_ve[text_number], sizeof name);

There is no need for the cast to char*, Bet_ve[text_number] is already a const char*.

How is name being used? Many functions, such as print(), can take a char array directly from PROGMEM, making the ram copy unnecessary.

You are totally right

const char Bet_ve[6][10] PROGMEM = {
  "text1", "text2", "text3 ", "text4", "text5 ", ""
};

char name[10];

void getText(uint8_t text_number) {
  if (text_number >= sizeof Bet_ve / sizeof Bet_ve[0]) {
    name[0] = '\0';
    return;
  }
  strlcpy_P(name, Bet_ve[text_number], sizeof name);
}

And yes this is just in case