????? HELP!!! what is wring with this code? ???????

Joseph S. D. Yao jsdy at hadron.UUCP
Sat Oct 8 04:08:43 AEST 1988


In article <456 at mrsvr.UUCP> ssa at mrsvr.UUCP (6607) writes:
>"test.c", line 7: warning: illegal combination of pointer and integer, op =
...
>	and the funny part is when I run the same program in dbxtool (SUN WS)
>	IT RUNS FINE !!!!!!!!
[L1]>#include <strings.h>
[L2]>#define NULL (char *) 0
...
[L7]>	while((tokptr=strtok(strptr," \t")) != NULL ){

You do not mention under what machine or C compiler you get the error
message.  I suspect that, if you look in /usr/include/strings.h on
that system, you'll find that strtok() is not declared, while it is on
your Sun.  Since it is not declared, the C compiler believes that it
is a function returning 'int'.  (This is an historical bug from before
'void' existed.)

Although I like using system include files very much, I tend to try to
declare external functions in the body of each new function that uses
them.  This is good insurance in case - as here - one isn't properly
declared, or - as happens - the return value of function xxxfieonyou
in your massive project changes, in which case a later 'lint' run will
reveal the inconsistency.

	Joe Yao		jsdy at hadron.COM (not yet domainised)
	hadron!jsdy@{uunet.UU.NET,dtix.ARPA,decuac.DEC.COM}
	arinc,att,avatar,blkcat,cos,decuac,dtix,\
	ecogong,empire,gong,grebyn,inco,insight, \!hadron!jsdy
	kcwc,lepton,netex,netxcom,phw5,rlgvax,	 /
	seismo,sms,smsdpg,sundc,uunet		/



More information about the Comp.unix.questions mailing list