122 FAQ


  1. What if I missed my week 1 lab? If possible, go to another lab this week; tell the GTF that you're not in the lab. If all computers are occupied by students registered for the lab, you can be an observer. Space should open up as we progress through the first two weeks of the term.

    Also, the GTF will hold two extra sessions in the lab during week 2 devoted to the same material covered in the week 1 lab. The times of these lab sessions will be announced in class and posted to the 122 email list so add your name to the list asap.

  2. How do I get the lab I want when they are all full on DuckWeb?

    We are handling this informally. You do not have to use the DuckCall "exchange section" command (XS, 97) after it starts costing you $$ to do so. Here's what to do:

    Go to the lab you want and ask the GTF if there's room for you. If your GTF says Yes, make sure that s/he has your name removed from your original lab and added to the new one. If the GTF says No, you will have to attend a different lab.

    For labs that are full, two names may be added beyond the max, on the condition that the added students may have to watch over someone's shoulder when everyone registered attends the lab. Note that the originally registered students up to the max are guaranteed a seat. If you are one of the extra students added over the max and you have a notebook computer, bring it to the lab which is a wireless hotspot (and there are also Ethernet connections in the walls of B26 Kla if your notebook is not wireless enabled.)

  3. May I take CIS 122 P/N? Yes. 122 does not have to be taken for a grade to satisfy the B. Sci. math and computing requirement.

  4. I understand my UO account includes 1GB of disk storage on uoregon.edu. How can I monitor my disk usage on uoregon.edu?

    With respect to your disk quota, read the manual page for the du ("disk usage") by entering "man du" at the shell.

    Then you can use the du command as follows:

    This command will report one number, in Megabytes, for your total disk usage: du -sh

    This command will report one number, in Megabytes, for each of your directories, sorted from large to small: du -h | sort -r | more
  5. How do I Turn Off Keyword Highlighting in Emacs?
    To turn it off, edit ~/.emacs and put a semicolon (;) in front of this line:
    (global-font-lock-mode t))
  6. Emacs uses the Delete key to erase characters, but I prefer to use the Backspace key. How do I set it up?

    You have several options, as follows:
    1. Windows: Start SSH, select Edit > Settings > keyboard, then select Backspace sends Delete (or whichever key you want to use), then click OK.
    2. OS X: Start Applications > Utilities > Terminal, the select Terminal > Window Settings..., then select Keyboardin the drop-down list, then check Delete key sends backspace.
    3. Set your Unix shell's Erase key-- this is what Emacs uses by default.

      Use emacs to edit your login shell's startup file, .bash_profile: $emacs .bash_profile
      Add this line to the .bash_profile: stty erase '^h'
      save the file and exit emacs

  7. How can I get the path for the current directory displayed in my Unix prompt?

    Read Generic UNIX Interactive Prompts

  8. How can I define useful aliases in Unix? Use Emacs to add some of these aliases .bash_profile

    alias j jobs
    alias c clear # clear the display
    alias cw 'chmod 664' # make an .html file web accessible
    alias cx 'chmod 755' # set the standard mode for a directory
    alias cp cp -i # Ask before overwriting a file
    alias ed emacs
    alias h history
    alias k logout # kill
    alias ls ls -F # Marks dirs w/, links w/@, executables w/*
    alias ll ls -l # long listing
    alias ld ls -dl # show status of directory not contents
    alias lsx "ls -CR | more" # shows all files in all directories
    alias q fg # resume most recently suspended job
    alias rme "rm *~;rm #*#; ls" # remove all emacs backup files
    alias rmb "rm *.bak; ls" # remove all textpad backup files
    alias 1 %1 #resume job id = 1
    alias 2 %2 #resume job id = 2
    alias 3 %3 #resume job id = 3

  9. Misc Emacs Info:

    Cancel Command: cntrl-g. If you type an emacs command you did not intend, the results are often mysterious. You can cancel a running or partially typed command with cntrl-g. Some commands take two successive c-g's to terminate.

    Redisplay the screen: cntrl-l ("el", not the digit "1"). If the data on the screen looks wrong, type cntrl-l.

    The emacs backup file If you accidentally destroy or remove a file you are working on, note that emacs automatically creates a backup file when you open a file. Emacs appends a '~' to the file name being edited; thus, the backup file for tempCon.cpp is tempCon.cpp~.

    Emacs makes a backup for a file only the first time the file is saved in each editing session. No matter how many times you save a file in Emacs, its backup file continues to contain the contents from before you started the current emacs session.

    If you damage or lose a file, simply open the backup file in emacs: "emacs tempCon.cpp~" and then write it out (cntrl-x cntrl-w) to the original name, tempCon.cpp (not tempCon.cpp~).

  10. Why can't I use the name calc for an executable? Running "calc" starts a Unix program (unix calculator). Students can use the name "calc" if they run their program with the"./calc" command; or, by naming it something else like "myCalc".

  11. How can I output a time in digital format (hh:mm)?
    #include ‹iostream›
    using namespace std;
    
    //declare constants
    const char NUL = '\0';
    
    //declare functions
    void writeTime(int hr, int min);
    
    int main(){ 
       //. . .
       //display time in digital format
       writeTime(hr, min);
       //. . . 
    }
    
    /* writeTime() ====================================
     * displays time in digital format (hh:mm)
     */
    void writeTime(int hr, int min){
      cout << endl << ((hr < 10)?'0':NUL) << hr << ":"
           <<  ((min < 10)?'0':NUL) << min  << endl;
    }
    
    Note that this function is an exception to the general rule that functions do not use cout. Since the function is written specifically to perform output, it does use cout and the name of the function makes its purpose clear.

  12. The One-L NUL and the Two-L NULL.

    The ASCII character with the bit pattern of zero is termed a "NUL". The special pointer value that means the pointer points nowhere is "NULL". The two terms are not interchangeable in meaning. Although we will not be using pointers and NULL in 122, we will use characters and NUL. This little rhyme will help you remember there is a difference:
    The one-L NUL ends an ASCII string,
    The two-L NULL points to no thing.
    Apologies to Ogden Nash, but the three-L nulll means check your spelling. 
    	-- Peter van der Linden, Expert C Programming: Deep C Secrets
    
    
    The one-L lama, he's a priest
    The two-L llama, he's a beast
    And I will bet my silk pyjama
    There isn't any three-L lllama. 
    	 -- Ogden Nash
    
  13. How can I reverse the digits in a number?
    Algorithm dreverse
    
       prompt and read n
       reverse <- 0
    
       //reverse the order of digits in n
       while (n > 0)
          reverse <- reverse * 10	   // shift accumulator left
          digit <- n  % 10	           // copy rightmost digit of n
          reverse <- reverse + digit   // add digit on right end
          n <- n / 10		   // shift n right using INTEGER DIVISION
       od
    
    //display result
    print n, reverse
    
    End.