#include /* fprintf(3), stderr */ #include /* EXIT_FAILURE */ #if !defined EX_USAGE # define EX_USAGE EXIT_FAILURE #endif static char *program_name = "strcmp"; int main(int argc, char *argv[]){ int i; if(argc < 3){ fprintf(stderr, "Usage: %s [string] [string...]\n", argv[0] == NULL ? program_name : argv[0]); return EX_USAGE; } for(; *argv[1] != '\0'; ++argv[1]) for(i = 2; i < argc; ++i) if(*argv[i-1] > *argv[i]) return 1; else if(*argv[i-1] < *argv[i]++) return -1; /* actually 255 */ return 0; }