// WECP100/book/reads.c 20240729
// description: read from stdin simple using system call, on LINUX
// machine: laptop window11
// os: linux using wsl on windows11
//> wsl >> Welcome to Ubuntu 22.04.2 LTS //on power shell
//$ cat /etc/os-release >> PRETTY_NAME="Ubuntu 22.04.2 LTS"
//$ uname -a >> inux LAPTOP-2E5CQCBT 6.6.36.3-microsoft-standard-WSL2 #1
// >> Sat Jun 29 07:01:04 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
// language: gcc --version >> gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
//$ gcc reads.c -o reads
//$ ./reads 0123456789
// ./reads 1234567890
// 1234567890
#include< unistd.h> // read and write system calls.
#include< stdio.h> // perror function for error handling.
int main(){
char buf[4096]; // bUF_SIZE
int n = read(0, buf, sizeof buf); //read from stdin(file descriptor:0)
//if (n < 0) { // error heading n: read byte size
// perror("read:"); // heading error
// return 1; // error return
//}
write(1, buf, n); // write to stdout(file descriptor:1)
}
//--------------------------------------------------