be kind, save a byte
This commit is contained in:
parent
a490eb13ae
commit
a6f6736d12
@ -1,11 +1,7 @@
|
||||
all: streq
|
||||
streq: streq.c
|
||||
$(CC) -g -o streq streq.c
|
||||
|
||||
clean:
|
||||
rm -r streq
|
||||
rm -f streq
|
||||
|
||||
sane: streq
|
||||
|
||||
streq: streq.c
|
||||
$(CC) -o streq streq.c
|
||||
|
||||
.PHONY: all clean sane
|
||||
.PHONY: clean
|
||||
|
@ -6,7 +6,6 @@ static char *program_name = "streq";
|
||||
|
||||
int main(int argc, char *argv[]){
|
||||
int i;
|
||||
int j;
|
||||
|
||||
if(argc < 3){
|
||||
fprintf(stderr, "Usage: %s [string] [string...]\n",
|
||||
@ -14,10 +13,9 @@ int main(int argc, char *argv[]){
|
||||
return EX_USAGE;
|
||||
}
|
||||
|
||||
/* i is the arg index, j is the char index */
|
||||
for(j = 0; argv[1][j] != '\0'; ++j)
|
||||
for(; *argv[1] != '\0'; ++argv[1])
|
||||
for(i = 2; i < argc; ++i)
|
||||
if(argv[i-1][j] != argv[i][j])
|
||||
if(*argv[i-1] != *argv[i]++)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user