here, have an echo

#include <stdio.h> int main(int argc, char **argv) { for(char *s;(s = *(++argv))!=0;) printf("%s ", s); puts("\b"); }

@ivesen you should check argc before dereferencing argv or you risk dereferencing NULL ...

@Absinthe nah, I checked. argv[argc] is always null, and argc is at least 1.
Follow

@ivesen argc will be 1 to account for argv[0]. argv[argc] likewise should always be NULL or actually out of bounds depending on the compiler implementation since the last thing on the CMD line will be argv[argc-1]...

@Absinthe
chapter 5.1.2.2.1 defines argv[argv] explicitly as being null.
the only case this doesn't hold for is if argv you don't have a program name, at which point you're not working with an operating system any more
http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf

@ivesen okay, I'll give you that. But, not really my business anyway, you didn't ask for review. Occupational hazard. Forget I said anything.

Sign in to participate in the conversation
Qoto Mastodon

QOTO: Question Others to Teach Ourselves
An inclusive, Academic Freedom, instance
All cultures welcome.
Hate speech and harassment strictly forbidden.