--- In [email protected], "bobtransformer" <bobtransfor...@...> wrote: > > > Hi, and thank you for the help on my "expected an expression" problem from > this weekend. It now works !! > > So, I am trying to use memory very sparingly in my embedded system, as I > always try to do. > > I have a char array that is initialized to 128 bytes, say like this... > > char myarray[128]; > > Now, sometimes I want to re-use this array for ints and shorts, and I know > that it will be good for 64 shorts or 32 int values. I cannot just > type-cast like this: (int) myarray[2] = 123456; for instance. > > What is the best way to use this existing allocated memory for all 3 types of > data ?? I do not need to convert int data to char or anything like that. I > just want to use the array for the different types at different times in the > program. This array is only temporary storage for reading and writing data to > and from an EEprom.
OOops ! I just realized something... When using this array to read or write to/from the EEprom, it is being passed as a char array. I only want to fill the array or to extract data from the array in the 3 possible data types. It's looking to me more and more like it wants to be a "union" type, but thought I'd better check with you guys. This is one of my weaker "C" programming abilities. boB > > One method that comes to mind is a union, but I'm not sure if that is the > best way. > > Ideas ?? > > Thank you again ! > boB >
