more cleaning
This commit is contained in:
27
streq/streq.c
Normal file
27
streq/streq.c
Normal file
@@ -0,0 +1,27 @@
|
||||
#include <sysexits.h>
|
||||
#include <unistd.h>
|
||||
#include "libio.h"
|
||||
|
||||
static char *program_name = "streq";
|
||||
|
||||
int main(int argc, char *argv[]){
|
||||
int i;
|
||||
int j;
|
||||
|
||||
if(argc < 3){
|
||||
write(2, "Usage: ", 7);
|
||||
if(argv[0] == NULL)
|
||||
argv[0] = program_name;
|
||||
fdprint(2, argv[0]);
|
||||
write(2, " [strings...]\n", 14);
|
||||
return EX_USAGE;
|
||||
}
|
||||
|
||||
/* i is the arg index, j is the char index */
|
||||
for(j = 0; argv[1][j] != '\0'; ++j)
|
||||
for(i = 2; i < argc; ++i)
|
||||
if(argv[i-1][j] != argv[i][j])
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user