C   84

cd

Guest on 25th April 2022 10:21:56 PM

  1. /* cd.c program to emulate unix cd command */
  2. /* written by sHaDy */
  3. /* compile with gcc: cc cd.c -o cd */
  4.  
  5. #include<stdio.h>
  6. #include<sys/dir.h>
  7.  
  8. main(int argc,char **argv)
  9. {
  10.         if (argc < 2)
  11.           { printf("Usage: %s <pathname>\n",argv[0]);
  12.             exit(1);
  13.           }
  14.  
  15.         if (chdir(argv[1]) != 0)
  16.           { printf("Error in \"chdir\"\n");
  17.             exit(1);
  18.           }
  19. }

Raw Paste


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