I'm using Keil3 for arm. 1\I wanna change the string's content,eg from "2007" to "2008" 2\I wanna a pointer ,not a array,to point to the string. But when I do as follows: char *ptr = "2007"; ptr is in the flash area,so I cann't change the content of the string "2007" .
I define a struct for the button in LCD display:
typedef struct key { uint16 x; //x position in LCD uint16 y; //y position in LCD uint8 *text; //button name void (*onOK)(); //press down responsefunction struct key *next; }KEY;
and then put all the buttons in a linked-list so that I can change focus among the buttons by ptr->text. As the lengths of all the text aren't the same,I need to use pointer to save space instead of array. But sometimes I wanna change the content of ptr->text,so in the initialization I cann't do as follows: ptr->text = "2007"; //"2007" in flash I now do like this: char array[]="2007"; //"2007" in RAM ptr->text = array; //so is *(ptr->text) in RAM. All these happen because I didn't know that after the sentence:" ptr->text = "2007";",the string "2007" is in the flash.