Menu

Class 6: Homework


You must print this sheet out and write/type answers on it!

  1. The last example in the notes for this lecture is a program that computes the number of seconds left 'til graduation. Describe thoroughly what you would do to configure your Unix environment so that everytime you logged in, you would see how many seconds were left 'til graduation.
    
    
    
    
    
    
    	      
    	    
  2. Briefly describe the difference between a system call and a regular function call to either a function in a standard C library or a function you wrote.
    
    
    
    
    
    
    	      
    	    
  3. The end of section 6.10 from your textbook (APUE 2nd Edition) describes the C standard library function strftime. Using that function, give the four lines of code needed to print out the full name of the current day of the week. Note: you could make due with more or fewer depending.
       #include <stdio.h>
      
       #include <time.h>
    
       int main()
    
       {
    
    1: 
    
    2: 
    
    3: 
    
    4: 
    
         return 0
    
       }
    
    
    
    
    	      
    	    
  4. Assuming the following declarations:
    time_t T;
    struct tm *p;
    struct tm gd;
    	    
    Give the types of the following expressions, or "error" if they are invalid expressions.
    1. &T
    
    2. *p
    
    3. gd.tm_year
    
    4. gd->tm_year
    
    5. p.tm_year
    
    6. p->tm_year
    
    7. &gd.tm_year
    
    8. p
    
    9. (int)T