Advertisement
BenTibnam

Print file content through stdin redirection

Oct 7th, 2023
905
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.21 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main(void)
  4. {
  5.     char c;
  6.  
  7.     while ((c = getchar()) != EOF)
  8.     {
  9.         printf("%c", c);
  10.     }
  11.  
  12.     return 0;
  13. }
  14.  
  15. // ./bin < input_file will print the input file content to stdout
Tags: Linux stdin
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement