Created
April 5, 2021 06:53
-
-
Save alsamitech/eb8eddda96bd6dc11e463406640ca369 to your computer and use it in GitHub Desktop.
Simply reads from file descripter one (stdin) for as long as it goes, similar to cin.getline in C++, just thought I'd add this.
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 <stdio.h> | |
| #include <stdlib.h> | |
| #include <string.h> | |
| #ifdef __unix__ | |
| #include <unistd.h> | |
| #else | |
| #error Only supports unix! | |
| #endif | |
| int main(int argc, char** argv){ | |
| char x[10]; | |
| int n; | |
| while((n=read(0, x, 8))>0){ | |
| printf("\033[1;31m%d %s\033[0m\n", n, x); | |
| } | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment