Path: utzoo!utgpu!news-server.csri.toronto.edu!clyde.concordia.ca!ccu.umanitoba.ca!mills From: mills@ccu.umanitoba.ca (Gary Mills) Newsgroups: comp.lang.c Subject: Re: NULL pointer problem on SUN Message-ID: <1990Nov10.230033.1502@ccu.umanitoba.ca> Date: 10 Nov 90 23:00:33 GMT References: <1255@digi.lonestar.org> Organization: University of Manitoba, Winnipeg, Canada Lines: 27 In <1255@digi.lonestar.org> theruska@digi.lonestar.org (Thomas Heruska) writes: >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. You have a serious misconception about NULL. A NULL pointer does not point to a null character. In fact, a NULL pointer does not point at all. Neither is a NULL pointer the same as a null string. When you have a pointer that you suspect may be NULL, you must test the pointer before referring to the object at which the pointer points. This way should work on all the machines: char token[50]; char mesg[50]; char *ptr; strcpy(mesg," \0"); ptr = strtok(mesg," \0"); if ( ptr != NULL ) { strcpy(token, ptr); . . . -- -Gary Mills- -Networking Group- -U of M Computer Services-