#include
int main( int argc, char *argv[] ) { // imagine this coming from STDIN instead char *stringlist = "foo\0bar\0baz\0quux\0"; // double-NUL terminated!! while( *stringlist ) { printf( "%s\n", stringlist ); // imagine open() here instead while( *( stringlist++ ) ); // look ma, no copying! } return 0; }
Wow, my C is really rusty. Took me a moment to realize why the last while wasn't a bug
Re:Rusty
Aristotle on 2005-04-22T03:48:59
Yes, it’s very dense code. It took me a moment to get right!
:) If it wasn’t for the ineffably laborious tedium of memory micromanagement that is all too frequently necessary, I’d spend a lot more time writing C. (I see that as a failing of the standard library much more so than of the language itself.)