Why (long)NULL ?
From: sugaray (ruicui_at_sohu.com)
Date: 02/29/04
- Next message: Tim Prince: "Re: fork() problems"
- Previous message: Bill Cunningham: "Standard question"
- Next in thread: Richard Heathfield: "Re: Why (long)NULL ?"
- Reply: Richard Heathfield: "Re: Why (long)NULL ?"
- Reply: Ben Pfaff: "Re: Why (long)NULL ?"
- Reply: Greg Barron: "Re: Why (long)NULL ?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 28 Feb 2004 22:30:15 -0800
Hi, I just came upon this code snippet which parses a string stored in buf
with comma(,) as delimiter and store each substring into args, the question
I'm having here is that I don't get why in the first while-statement the OP
cast the NULL to a (long), isn't *buf a char ? and another question is what's
the purpose of NULL in string manipulation, and how to test to see if an input
string is empty ? Thanx for your help.
void parse (char *buf, char **args) {
while (*buf != (long) NULL ) {
while ( *buf == ',' )
*buf++ = (long) NULL ;
*args++ = buf;
while ( (*buf != (long) NULL) && (*buf != ',') )
buf++;
}
*args = NULL;
}
- Next message: Tim Prince: "Re: fork() problems"
- Previous message: Bill Cunningham: "Standard question"
- Next in thread: Richard Heathfield: "Re: Why (long)NULL ?"
- Reply: Richard Heathfield: "Re: Why (long)NULL ?"
- Reply: Ben Pfaff: "Re: Why (long)NULL ?"
- Reply: Greg Barron: "Re: Why (long)NULL ?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|