Tutorial Exercises Week 9

  1. Use the online manual to read the entry in section three for ``getwd''. Write a program to print your current working directory. Note the use of MAXPATHLEN - no complete pathname is allowed to be longer than that.
  2. Use the online manual to read the entry in section two (man -s 2 chdir) for ``chdir''. Write a program to read directory names from standard input until end-of-file and change the current working directory. What patterns are recognised out of `.', `..', `~', etc?
  3. Write a program to read a single line of input and execute this as a command using the call ``system''. Can this handle ``cd'', or must you treat this as a special case?
email: jan@newmarch.name
Web: http://jan.newmarch.name/
Last modified: 10 April 2001