C   22

yes.c

Guest on 5th May 2022 10:52:21 PM

  1. /*      yes 1.4 - print 'y' or argv[1] continuously.    Author: Kees J. Bot
  2.  *                                                             
  3.  */
  4. #include <sys/types.h>
  5. #include <stdlib.h>
  6. #include <string.h>
  7. #include <unistd.h>
  8.  
  9. int main(int argc, char **argv)
  10. {
  11.         char *yes;
  12.         static char y[] = "y";
  13.         int n;
  14.  
  15.         yes= argc == 1 ? y : argv[1];
  16.  
  17.         n= strlen(yes);
  18.                
  19.         yes[n++]= '\n';
  20.  
  21.         while (write(1, yes, n) != -1) {}
  22.         exit(1);
  23. }

Raw Paste


Login or Register to edit or fork this paste. It's free.