wc/wc.c

23 lines
405 B
C

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