Created
March 23, 2023 00:01
-
-
Save lostsh/673cc92bb85cc0b370092c237b4de82c to your computer and use it in GitHub Desktop.
C99 input from pipe ouput stdout
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <unistd.h> | |
| /** | |
| * Read input char by char and ouput it. | |
| */ | |
| int main(int argc, char* argv[]){ | |
| int read_status = 1; | |
| while(read_status){ | |
| char c; | |
| read_status = read(STDIN_FILENO, &c, 1); | |
| // eventually do things | |
| write(STDOUT_FILENO, &c, 1); | |
| } | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
pipe.cWith memory allocation in a proper function