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) {
|
while (read(fn, c, sizeof(c)) > 0) {
|
||||||
printf("%c", c[0]);
|
printf("%c", c[0]);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
if (!isatty(STDIN_FILENO)) {
|
if (!isatty(STDIN_FILENO)) {
|
||||||
return process_fn(STDIN_FILENO);
|
return process_fn(STDIN_FILENO);
|
||||||
} else if(argc > 1){
|
} else if (argc > 1) {
|
||||||
FILE* fp = fopen(argv[1], "r");
|
FILE* fp = fopen(argv[1], "r");
|
||||||
if(!fp){
|
if (!fp) {
|
||||||
perror("Could not open file");
|
perror("Could not open file");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return process_fn(fileno(fp));
|
return process_fn(fileno(fp));
|
||||||
} else{
|
} else {
|
||||||
printf("To do");
|
printf("To do");
|
||||||
|
}
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user