1

Given:

const char* PROGMEM names[] = {"Foo","Bar"};
Serial.print(names[0]);

I get garbage output. Is there some function that will print the string from PROGMEM? E.G.:

Serial.print(<function name>(names[0]);
Glorfindel
5781 gold badge7 silver badges18 bronze badges
asked Feb 5, 2019 at 16:12
2
  • 1
    That's not how you use PROGMEM. You need to use the functions pgm_read_***_near Commented Feb 5, 2019 at 16:33
  • 1
    your strings are not in progmem. only the array of pointers to strings is there arduino.cc/reference/en/language/variables/utilities/progmem Commented Feb 5, 2019 at 18:26

2 Answers 2

2

Among many others, check out pgmspace.h utilities at AVR-libc

answered Feb 7, 2019 at 4:23
0
const char PROGMEM b0 = pgm_read_dword(&(names[0]));
Serial.print(b0);
Nick Gammon
38.9k13 gold badges69 silver badges125 bronze badges
answered May 6, 2023 at 22:48
1
  • 2
    PROGMEM does nothing here Commented May 7, 2023 at 5:12

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.