Getting Started


After you have logged in on any available workstation, move the mouse to your xterm window.
 
  • Create a subdirectory "euclid" in your home directory by typing the following Unix command:

  • mkdir euclid

    "Euclid" is the name of the program you will be editing and debugging in this walkthrough. In order to work with this file, you need to copy it to the directory you created, so start by changing to that directory.
     
  • Type in the following command in the xterm window:

  • cd euclid
  • Now get a copy of the "Euclid" program source code by using the following command (including the almost-invisible period (".") at the end, which is preceded by an invisible space):

  • cp /class/sce/reference/rcpp/Euclid.cpp .

    This command will copy the program into the current directory. The first argument after cp is the source of the copy (/class/sce/reference/rcpp/Euclid.cpp is the source in this example), and the second argument is the destination to which the file is copied. You can type the entire directory name, but if you use a ".", the file will automatically be copied into the current directory. In this example, your current directory is "euclid" within your personal home directory.

    Now you are ready to start editing and debugging the program.
     
  • Load the program into XEmacs by hitting Ctrl-x Ctrl-f
  • Enter the name of the file you wish to load: ~/euclid/Euclid.cpp at the prompt on the bottom of the screen. 
  • Alternatively, you can use your mouse to open a file by clicking on the "Files" menu and then scrolling down to "Open...". You will be get a "file dialog" that works similarly to those on Macs and Windows machines. Or, if you wish, you can use the "dired" (directory edit) feature of XEmacs to first open the directory and then open the file from there.

    Take a quick look at the Euclid.cpp program. The program is not yet complete and it has a number of syntax and logical errors. Your task will be to complete the editing and debugging of the program so that it correctly computes the greatest common divisor of two numbers using Euclid's algorithm.

    Even if you spot the errors now, do not correct them yet! Wait until you see the error messages that will be produced.



    Previous Table of Contents Continue


    Last modified: Mon Jan 17 15:25:41 EST 2005