[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-gcc-list] I am getting lost in indirections - help please
From: |
Juergen Harms |
Subject: |
Re: [avr-gcc-list] I am getting lost in indirections - help please |
Date: |
Thu, 15 Mar 2007 18:56:10 +0100 |
User-agent: |
Thunderbird 1.5.0.10 (X11/20070305) |
I want to fill the array "buffer" with the name of a weekday that (I
hope) is stored in an array in flash memory (in fact, I intend to store
in flash both an array of pointers and the character strings they
pointers point to).
Here is what I have tried, and what does not work. I am a newby to this
kind of indirection acrobacy, what have I figured out wrong ? (I use
strncpy_P rather than stcpy_P to avoid the garbage I get to do damage)
static const prog_char *day_names[] =
{ (const PROGMEM char *) "",
(const PROGMEM char *) "Mon",
(const PROGMEM char *) "Tue",
(const PROGMEM char *) "Wed",
(const PROGMEM char *) "Thu",
(const PROGMEM char *) "Fri",
(const PROGMEM char *) "Sat",
(const PROGMEM char *) "Sun" } ;
// Copy indexed string (name of Tue) to buffer, print it
void dummyprog () {
uint16_t ptr ;
char buffer[4] ;
ptr = pgm_read_word_near ( (PGM_P) day_names[2] ) ;
strcpy_P ( buffer, (PGM_P) ptr ) ;
printf ( "@@@@ %s\n", buffer ) ;
}