Next: list.c Up: Program Listings Previous: print.c

cdir.c


/* cdir.c program to emulate unix cd command */

/* cc -o cdir cdir.c */


#include<stdio.h>
/* #include<sys/dir.h> */

main(int argc,char **argv)
{
	if (argc < 2)
	  { printf("Usage: %s <pathname>\n",argv[0]);
	    exit(1);
	  }

	if (chdir(argv[1]) != 0)
	  { printf("Error in \"chdir\"\n");
            exit(1);
          }
}


Dave.Marshall@cm.cf.ac.uk
Wed Sep 14 10:06:31 BST 1994