progmem data as argument to function [solved]

Hello,

Can someone please help with a sample code for passing flash strings to a function?
below trials with named and inline strings - It'd really nice to have a solution for both

Many thanks

const char astring[] PROGMEM = {"blabla"};
char genBuf[200];
void setup() {
  Serial.begin(38400);
  while (!Serial);
  Serial.println("starting");
  genBuf[0]='\0';
  cat1(astring);// named strings - compiles ok and prints 28 squares
  cat2(F("blibli"));// inline strings - does not compile
  Serial.print(genBuf);
}
void cat1(const char* string) {strcat(genBuf, string);}
void cat2(const __FlashStringHelper* string) {strcat(genBuf, string);}

void loop(void){;}

edit 12 Jul '19 the solution

void cat1(const char* string) {strcat_P(genBuf, string);}
void cat2(const __FlashStringHelper* string) {strcat_P(genBuf, (PGM_P)(string));}

Shouldn't the second form use "strcat_P" ?

and first one too

Oh, yeah.

Gonna need a bigger screen.

guy_c

any operation with pointer stored in progmem only via *P function
and sure pgm_read

Awol, Alexblade, Thanks a lot!

Now #1 compiles and run OK Youpee

as for #2, I am getting
progmem1:13: error: cannot convert 'const __FlashStringHelper*' to 'const char*' for argument '2' to 'char* strcat_P(char*, const char*)'
line 13 is where cat2 is defined. Is it possible at all to call a function with F(string) w/o defining the string with PROGMEM ? ... except of cours for Serial.print or client.print

here is the code modified per your recommendation

const char astring[] PROGMEM = {"blabla"};
char genBuf[200];
void setup() {
  Serial.begin(38400);
  while (!Serial);  // wait for serial port to connect. Needed for native USB
  Serial.println("starting");
  genBuf[0]='\0';
  cat1(astring);// named strings - compiles ok and prints 28 squares
  cat2(F("blibli"));// inline strings - does not compile
  Serial.print(genBuf);
}
void cat1(const char* string) {strcat_P(genBuf, string);}
void cat2(const __FlashStringHelper* string) {strcat_P(genBuf, string);}

void loop(void){;}

@Alexblade, I think that there is no pointer stored in flash here, only a string

resolution in 1st post