Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!newstop!texsun!digi.lonestar.org From: theruska@digi.lonestar.org (Thomas Heruska) Newsgroups: comp.lang.c Subject: NULL pointer problem on SUN Message-ID: <1255@digi.lonestar.org> Date: 9 Nov 90 23:03:32 GMT Sender: theruska@digi.lonestar.org Organization: DSC Communications, Plano Tx. Lines: 34 I am having trouble using the function strtok on a SUN. The function works perfectly on an HP and APOLLO system, so I am convinced that it is a specific SUN problem. I believe that the problem occurs due to the fact strtok returns a NULL pointer when it encounters the end of the string it is parsing. I am trying to copy this NULL pointer to another string and check that string for the NULL. For some reason, it crashes at this point ONLY on the Sun. Has anyone encountered this problem before? It is obviously not a problem with strtok, but rather with copying a NULL pointer to a string. The man pages on strtok state that a pointer to a null string must be used instead of a NULL pointer on the Sun. However, strtok only returns a NULL pointer. I have tried casting (char *) to the returned value from strtok, but it produces the same results. portion of code: char token[50]; char mesg[50]; strcpy(mesg," \0"); strcpy(token,strtok(mesg," \0")); /* crashes here - should place a NULL pointer in token */ if (token[0] == NULL) . . . Does anyone know how to get around this on a SUN? Please E-mail any suggestions. Thanks in advance.