From: "Cherlene Lim" <[EMAIL PROTECTED]>
> can I know how to set a character pointer to null value?
I'm not sure if you want to set the character pointer to null or you want to
do something to the characters it points to, but perhaps these examples will
help:
Char temp[3]; // this will be used later
Char myChars[3] = ""; // puts \0 into myChars[0], making myChars an
"empty" string
Char * myCharP = myChars; // sets the character pointer myCharP to the
address of myChars
StrCopy(myChars, "abc"); // puts 'a', 'b', 'c', \0 into myChars[0],
myChars[1], etc.
StrPrintF(temp, "%s", myChars); // copies "abc" to temp
StrPrintF(temp, "%s", myCharP); // also copies "abc" to temp since
myCharP "points to" myChars
StrCopy(myCharP, ""); // puts \0 into myChars[0], which is still pointed
to by myCharP
myCharP = NULL; // sets the character pointer myCharP to the null
address, has no effect on myChars
Do not attempt to use myCharP while it is null. You can test it like this:
if (! myCharP)
{
// do something with it...
}
Or, if it seems clearer to you, use:
if (myCharP != NULL)
{
// do something with it...
}
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palm.com/devzone/mailinglists.html