Reading from stdin
What are the possible ways for reading user input using read() system call in Unix. How can we read from stdin byte by byte using read() ? You can do something like this to read 10 bytes: char buffer[10]; read(STDIN_FILENO, buffer, 10); remember read() doesn't add '\0' to terminate to make it string (just gives raw buffer). To read 1 byte at a time: char ch; while(read(STDIN_FILENO, &ch, 1) > 0) { //do stuff } and don't forget to #include <unistd.h> , STDIN_FILENO defined as macro in this file. There are three standard POSIX file descriptors, corresponding to the three standard streams, which