I am trying to set the first character in a char array within a structure equal to a character using:
aRecord->Ground[0] = 'u'; When I run this, the compiler tells me that I'm accessing memory incorrectly, and should use special means of accessing memory. ----- Original Message ----- From: "Russell Cagle" <[EMAIL PROTECTED]> To: "Palm Developer Forum" <[email protected]> Sent: Tuesday, November 01, 2005 3:50 PM Subject: Re: I hate to ask > I think you said you're using an array of characters: > > struct Record { > char Ground[1]; > }; > > If so, you also need to compare 'u' to the first character in the array, > like this: > > if (aRecord->Ground[0] == 'u') { > } > > > Robert Moynihan wrote: > > Del Ventruella wrote: > > > >> This is basic C++. I could substitute an integer, but would like to > >> understand how to make this work in the manner in which I originally > >> intended. If anyone has a spare moment, please respond. > >> > >> Essentially, I have a structure that includes a char (char[1]). I > >> assign it a value based upon the state of some device. In this case, > >> "s" or "u". I would like to then use this in a boolean expression, > >> such as: > >> > >> if (aRecord->Ground=="u") > >> > >> > > You are comparing aRecord->Ground to the pointer address for the > > string. You'll always get false, I should think. > > > >> { > >> FrmSetControlValue(frmP, FrmGetObjectIndex(frmP, UnGnd),1); > >> } > >> > >> Unfortunately, "aRecord->Ground=="u", always returns "false", even > >> when I set its value equal to "u". I seem to be dealing with some > >> issue of accessing the zeroth character in the string within the > >> structure, but I could be misinterpreting this. I'm simply not sure > >> how to do this. The char was declared as: Ground[1]. > >> > > Do it like this instead: > > > > if (aRecord->Ground=='u') > > > > So you are just looking at the value of that one character. > > > > Bob > > > > > > > > > > -- > For information on using the PalmSource Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/ > -- For information on using the PalmSource Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
