Mike,

I don't see anything wrong with the code that you've posted. Nor did I
encounter any errors when compiling and running the code that you posted.

You might want to (a) double check your sample and (b) give additional
information on just what error your getting.

-- Keith Rollin
-- Palm OS Emulator engineer






"Mike Davis" <[EMAIL PROTECTED]> on 04/18/99 07:24:42 PM

Please respond to [EMAIL PROTECTED]

To:   [EMAIL PROTECTED]
cc:    (Keith Rollin/HQ/3Com)
Subject:  Pointer Error question




I have a strange problem that is driving me nuts (easily done).
I have a function that is passed a pointer to char.  I then
parse the string pointed to by the pointer.  I check the
characters and decide if I want to stop.
Anyway, the first way I tried to do this always produced an
error so I came up with a different way.  The second way
never produces an error.
I'm wondering if someone can tell me the difference and why one
causes a run-time error and one does not?  The pointer (ptr) is
initialized and points to a valid number.  The character tested
may be NULL, if end of string is reached.  The first 'if' statement
always generates an error and the 2nd does not.  Why?
int TestFunction(char * ptr)
{
    char tmpChar;
    tmpChar = *ptr; // *ptr may be NULL
    // always generates run-time
    if(tmpChar != ':' && tmpChar != ';')  { // some code }
    // never generates run-time error
    if(*ptr != ':' && *ptr != ';')  { // some code }
// additional code not shown
What is the technical difference that might cause one to generate
a run-time error and one does not?

--
-----------------------------------------------------------------
Discussion Group:        http://www.halcyon.com/ipscone/wwwboard/
Protect your constitutional rights. Your favorite one may be next!
-----------------------------------------------------------------









Reply via email to