Created
August 22, 2014 05:48
-
-
Save zodiac1111/fa320f700b43a6e9e25d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
** CMDLINE.C - Demonstrates accessing command line arguments | |
*/ | |
#include <stdio.h> | |
/// "string"[index] 不常见的用法 | |
#define plural_text(n) &"s"[(1 == (n))] | |
#define plural_text2(n) &"es"[(1 == (n)) << 1] | |
main(int argc, char *argv[]) | |
{ | |
int i, n = argc - 1; | |
printf("You passed %d argument%s on the command line.", | |
n, plural_text(n)); | |
if (argc > 1) | |
{ | |
puts(" They are:"); | |
for (i = 1; i < argc; ++i) | |
{ | |
printf("\nArgument #%d:\n Text: \"%s\"\n Value: %d\n", | |
i, argv[i], atoi(argv[i])); | |
} | |
} | |
else putchar('\n'); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment