[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: |
Eric Weddington |
Subject: |
RE: [avr-gcc-list] I am getting lost in indirections - help please |
Date: |
Thu, 15 Mar 2007 14:15:48 -0600 |
Avr-libc user manual, FAQ, #14:
<http://www.nongnu.org/avr-libc/user-manual/FAQ.html#faq_rom_array>
> -----Original Message-----
> From:
> address@hidden
> [mailto:address@hidden
> org] On Behalf Of Juergen Harms
> Sent: Thursday, March 15, 2007 11:56 AM
> To: address@hidden
> Subject: Re: [avr-gcc-list] I am getting lost in indirections
> - help please
>
> 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 ) ;
> }
>
>
>
> _______________________________________________
> AVR-GCC-list mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/avr-gcc-list
>