copy contents from PROGMEM to const char []

203 Views Asked by At

What is the best way to copy a string form PROGMEM to a const char[]?

While something like this would probably work:

#include <avr/pgmspace.h>
const char *pstr = PSTR("Hello");
char str[strlen_P(pstr)+1];
strcpy_P(str, pstr);
const char *cstr = str;

Maybe there is a solution using an initializer_list object returned by a lambda with pgm_read_byte inside, similar to http://www.cplusplus.com/forum/beginner/213574/?

0

There are 0 best solutions below