formatting pass.

This commit is contained in:
NunoSempere 2023-09-08 23:23:18 +02:00
parent aef8269a68
commit 443b7503f9

25
wc.c
View File

@ -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;
}