wc/wc.c

23 lines
405 B
C
Raw Normal View History

#include <stdio.h>
2023-09-08 21:02:54 +00:00
#include <unistd.h> // read, isatty
2023-09-08 21:02:54 +00:00
// STDIN_FILENO
int process_fp(int filenum)
2023-09-08 21:02:54 +00:00
{
char buffer[1];
while (read(filenum, buffer, sizeof(buffer)) > 0) {
2023-09-08 21:02:54 +00:00
printf("%c", buffer[0]);
}
return 0;
}
int main(int argc, char** argv)
{
if (!isatty(STDIN_FILENO)) {
2023-09-08 21:02:54 +00:00
return process_fp(STDIN_FILENO);
} else if(argc > 1){
printf("To do");
}
return 0;
}