formatting pass.
This commit is contained in:
parent
aef8269a68
commit
443b7503f9
25
wc.c
25
wc.c
|
@ -8,23 +8,22 @@ int process_fn(int fn)
|
|||
while (read(fn, c, sizeof(c)) > 0) {
|
||||
printf("%c", c[0]);
|
||||
}
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
if (!isatty(STDIN_FILENO)) {
|
||||
return process_fn(STDIN_FILENO);
|
||||
} else if(argc > 1){
|
||||
FILE* fp = fopen(argv[1], "r");
|
||||
if(!fp){
|
||||
perror("Could not open file");
|
||||
return 1;
|
||||
}
|
||||
return process_fn(fileno(fp));
|
||||
} else{
|
||||
printf("To do");
|
||||
|
||||
}
|
||||
return process_fn(STDIN_FILENO);
|
||||
} else if (argc > 1) {
|
||||
FILE* fp = fopen(argv[1], "r");
|
||||
if (!fp) {
|
||||
perror("Could not open file");
|
||||
return 1;
|
||||
}
|
||||
return process_fn(fileno(fp));
|
||||
} else {
|
||||
printf("To do");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user