// Intro to Systems Programming, the C Language, and Tools for Software Engineering // https://www.bilibili.com/video/BV1Mu411Q7Md // https://www.youtube.com/watch?v=Rhf6iOeahk8 #include #include #define BUFFER_SIZE 80 char buffer[BUFFER_SIZE]; //int main() //{ // read(0, buffer, 5); // write(1, buffer, 3); //} // //gcc cat.c // ./a.out // //input: 123456 //output: 123 //6: is not a command //int main() //{ // ssize_t bytes_read; // bytes_read = read(0, buffer, 5); // write(1, buffer, bytes_read); //} //input: 1234567 //output: 12345 //7: command not found... //int main() //{ // ssize_t bytes_read; // bytes_read = read(0, buffer, 80); // write(1, buffer, bytes_read); //} //input: 12345 //output: 12345 int main() { ssize_t bytes_read; bytes_read = read(0, buffer, 80); write(1, buffer, bytes_read); } // ...