code unexplained behavior

Pages: 12
Though when pointer come into play it is always dangerous.
const DeviceStateStructure* dsspDeviceState // A pointer to the state structure of given device.
= &(s_dssaDevices[swDevice]);
Is the value of dsspDeviceState correct? It depends on the memory of s_dssaDevices and whether swDevice is out of bounds or not.


I didn't understand what do you mean by: "It depends on the memory of s_dssaDevices and whether swDevice is out of bounds or not"

What came before is:
static DeviceStateStructure s_dssaDevices[sitalMaximum_DEVICES] = {}; // An array of device state information.
s_dssaDevices defined as global static
sitalMaximum_DEVICES defined as 8

I assign pointer to represent swDevice state structure
What could be the problem here?
What could be the problem here?


Well, you've created the array s_dssaDevices[], but there's nothing to show that you put anything in it!
Well, we do see that there are sitalMaximum_DEVICES number of DeviceStateStructure objects in it.
Peter87 wrote:
Well, we do see that there are sitalMaximum_DEVICES number of DeviceStateStructure objects in it.


Well, it's an array of that size - but every element is the same and they may or may not have been initialised, depending on what a DeviceStateStructure is.
Topic archived. No new replies allowed.
Pages: 12