Hallo, i have not understand the difference of locating constants in the following example: Txt1 is located in Rom, while Txt2 (declared inside a function) is a variable in Ram and will be copied in ram.
const char Txt1[] = "Hallo1"; void main(void) { const char Txt2[] = "Hallo2"; char c1, c2; c1 = Txt1[0]; c2 = Txt2[0]; while(1) ; }
The 'const' qualifier on a top level (file scope) declaration permits the implementation to place the variable in read-only storage. This is not so with a const qualified automatic variable. If you want to ensure these strings are both stored in code space use the 'code' qualifier.