reading char array from PROGMEM?

Hi~ I have a lot of static data to store - in the form of multidim char arrays of varying lengths. I figure this is a good opportunity to learn about PROGMEM since I haven’t used it before.

Looking at the reference pg (http://www.arduino.cc/en/Reference/PROGMEM) I get some of it but… not quite. Before I start just poking the code I thought I would ask here.

In the sketch below, what I would like to do is get a pointer to CHR_21 and then be able to step through it without knowing it’s length.

#include <avr/pgmspace.h>

PROGMEM prog_char CHR_21[][2]={{10,0},{5,21},{5,7},{128,128},{5,2},{4,1},{5,0},{6,1},{5,2}};
 
char *buffer;
 
void setup(){
  Serial.begin(115200);
}


void loop(){
  
  strcpy_P(buffer, (char*)pgm_read_word(&CHR_21));
 
 
 for(; *buffer; buffer++){
   
   Serial.println(buffer[0]);
 Serial.println(buffer[1]);
 }
 
 delay(500);
}

What you want to do is move the address calculations before the progmem fetch. Addresses are addresses, and it doesn’t matter if wait until the very end to actually tell the program to address the progmem instead of the ram

PROGMEM prog_char CHR_21[][2]={{10,0},{5,21},{5,7},{128,128},{5,2},{4,1},{5,0},{6,1},{5,2}};

char *buffer;

void setup(){
  Serial.begin(115200);
}

void loop(){

 for(i = 0; true; i++){
  Serial.println(pgm_read_byte(&CHR_21[i][0]);
  Serial.println(pgm_read_byte(&CHR_21[i][1]);
  if (end_of_array(...))  // better do something!
    break;
  }
}