PROGMEM and Serial.print


is possible c++ function overloading tell difference between a string in progmem , "normal string" in ram?  casting typedef "prog_char" (as defined in pgmspace.h) doesn't seem sufficient (i guess both resolve same basic type far c++ concerned?)

i wondering myself, , little sketch seem show answer "yes":

code: [select]
#include <avr/pgmspace.h>

char string[] = "string1";
char progmem pstring[] = "string2";

class foo
{
public:
 void f(char *p)
 {
   serial.print("in char * version of f: ");
   serial.println(p);
 }

 void f(pgm_p p)
 {
   char buf[20];
   strcpy_p(buf, p);
   serial.print("in pgm_p version of f: ");
   serial.println(buf);
 }
};

void setup()
{
 foo f;
 serial.begin(9600);
 f.f(string);
 f.f((pgm_p)pstring);
}

void loop(){}


mikal


Arduino Forum > Forum 2005-2010 (read only) > Software > Syntax & Programs > PROGMEM and Serial.print


arduino

Comments

Popular posts from this blog

CAN'T INSTALL MAMBELFISH 1.5 FROM DIRECTORY - Joomla! Forum - community, help and support

error: expected initializer before 'void'

CPU load monitoring using GPIO and leds - Raspberry Pi Forums