I am looking for the following: struct room { char* name; char* location; } room[2] = { {"Hallway1", "Home"}, {"Hallway2", "Home"} }; I want to use a pointer in room[1].location to room[0].location instead of using the default mechanism to concatenate strings. I might want to use Hidden64 to put some strings in hidden RAM later. From: Ullrich von Bassewitz <uz@musoftware.de> To: cc65@musoftware.de Sent: Saturday, July 9, 2011 8:07 PM Subject: Re: [cc65] Repeated string in struct array On Fri, Jul 08, 2011 at 10:41:49AM -0700, Joseph Rose wrote: > Let's say I am defining an array of a struct type. The struct has a char* > field. The field in subscript 3 is the same as the one in subscript 2. I > want to shorten #3 to an offset to #2's data. How do I do that? I don't know exactly what you mean. When using string literals, the compiler will usually merge even partial strings. So in the example struct { const char* s; } bar[] = { { "hello world" }, { "world" }, }; there is only one string "hello world" and the second char pointer points into the same storage. Regards Uz -- Ullrich von Bassewitz uz@musoftware.de ---------------------------------------------------------------------- To unsubscribe from the list send mail to majordomo@musoftware.de with the string "unsubscribe cc65" in the body(!) of the mail. ---------------------------------------------------------------------- To unsubscribe from the list send mail to majordomo@musoftware.de with the string "unsubscribe cc65" in the body(!) of the mail.Received on Mon Jul 11 15:29:19 2011
This archive was generated by hypermail 2.1.8 : 2011-07-11 15:29:24 CEST