passing PROGMEM arrays to a function [SOLVED]

I read the very clear explanation of Nick Gammon on storing arrays of strings into PROGMEM (and reading them).

I chose the alternative without having to use a ‘struct’ and this works.

However, I have an issue when I want to pass these arrays of strings to a function.

My current code (to read out the status of a battery) gives a compiler error:

const char safety_status[16] [5] PROGMEM = {{"SCD "},{"SCC "},{"AOCD"},{"WDF "},{"RSVD"},{" PF "},{"COV "},{"CUV "},
                                            {"RSVD"},{"RSVD"},{"OCC2"},{"OCD2"},{"OCC "},{"OCD "},{"OT1C"},{"OT1D"}};

void report_failures() {
     print_fail(ss,safety_status);   // variable 'ss' is declared and already known elsewhere

    // later other registers with their respective contents have to be processed
    // that's why I wrote 'print_fail' 

void print_fail(uint16_t reg, char *fault) { 
     char buf[5];                     // temp buffer 
     for (uint8_t j=0; j<16; j++) { 

            if (bitRead(reg,j)) {           // if high then fault

              memcpy_P(&buf,&fault[j],sizeof(buf));      // copy fault name to temp buffer

              Serial.print(buf);Serial.println(F(" fault"));

The error I get is:

cannot convert 'const char (*)[5]' to 'char*' for argument '2' to 'void print_fail(uint16_t, char*)'

Amen. . .

The are moments where the *'s dazzle me, and this is one of them ; -)

void print_fail(uint16_t reg, const char fault[][5]) {

Can’t say if it’ll help but this prints directly from flash:

Array initialization:

  Laser error message code/TEXT structure/array creation
const byte noOfErrMsgs = 10; // future test: if this were in an array, could the size then be determined
// and used below?

const char LasErrSt0[] PROGMEM = "System Error";
const char LasErrSt1[] PROGMEM = "ECE Failure";
const char LasErrSt2[] PROGMEM = "Convergence fail";
const char LasErrSt3[] PROGMEM = "Range Ignore";
const char LasErrSt4[] PROGMEM = "SNR Error";
const char LasErrSt5[] PROGMEM = "Raw Underflow";
const char LasErrSt6[] PROGMEM = "Raw Overflow";
const char LasErrSt7[] PROGMEM = "Range Underflow";
const char LasErrSt8[] PROGMEM = "Range Overflow";
const char LasErrSt9[] PROGMEM = "Sensor not found";

typedef struct  {          // create structure for 6180 errors
  int8_t errorCode;        // 6180 error code no.
  const char* errorText;   // error description
} laserErr_t;

const laserErr_t laserMsg[noOfErrMsgs] PROGMEM = {
  {1, LasErrSt0},
  {6, LasErrSt1},
  {7, LasErrSt2},
  {8, LasErrSt3},
  {11, LasErrSt4},
  {12, LasErrSt5},
  {13, LasErrSt6},
  {14, LasErrSt7},
  {15, LasErrSt8},
  {99, LasErrSt9}

And this prints - to LCD

/*  laser error messages will fit on one line of lcd. can print "Laser Error" on top line,
     error type on bottom line. store in progmem

  VL6180X_ERROR_SYSERR_1 thru VL6180X_ERROR_SYSERR_5 = code 1-5

  VL6180X_ERROR_ECEFAIL = code 6



  VL6180X_ERROR_SNR = code 11

  VL6180X_ERROR_RAWUFLOW = code 12

  VL6180X_ERROR_RAWOFLOW)= code 13

  VL6180X_ERROR_RANGEUFLOW = code 14

  VL6180X_ERROR_RANGEOFLOW = code 15

  credits: John Wasser -

void displayLaserError(int errNum) {
  char * message;  // Pointer to PROGMEM address of message
  lcd.print("Laser Err no. ");
  if (errNum <= 5) errNum = 1; // Error no's 1-5 encompassed by code '1'
  for ( int i = 0;  i < noOfErrMsgs;  i++) { // Nine original error messges
    // One user-added code 99 'sensor not found'

    if (errNum == pgm_read_byte(&laserMsg[i].errorCode)) {
      // Found the message that matches the error code
      message = pgm_read_word(&laserMsg[i].errorText);  // Get message's PROGMEM address
      lcd.setCursor(0, 01);
      lcd.print( (__FlashStringHelper*) message); // prints directly from PROGMEM
      break;  // Don't bother looking for another match
  //Serial.print("unrecoverable laser error - code ");
  while (1);

@gfvalvo: I tried this and it works.

Thank you very much!

@dougp: also thanks for your efforts!