Sometimes I like C a lot

Aristotle on 2005-04-22T02:56:06

#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; }


Rusty

Ovid on 2005-04-22T03:24:08

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.)

there are a lot of reasons to like C (yes, really)

spur on 2005-04-22T06:54:15

And one of them is the beutifully concise code one can write for such string manipulation tasks. I just *love* seeing them pointers fly :-)