CSE271: Short Quiz #4 -- C Pointers

  1. Your name, today's date (2 points)
  2. Is there anything wrong with this code? If so, what is it? (2 points)
       #include <string.h>
    
       char string1[] = "Hello, world!";
       char *string2;
    
       strcpy(string2, string1);
    
  3. At the end of this code, what is the value of i? (2 points)
       int i = 5;
       int *p1, *p2;
    
       p1 = &i;
       p2 = p1 - 1;
    
       i++;
       i = *p1;
    
  4. What is the name of the library call that returns memory to the operating system that had originally been allocated using malloc()? (2 points)
    
    
    
  5. (2 points) What is the command in gdb to see the sequence of functions that were called to get to the current location in the program?


Last revised: 21 February 2013, Brian D. Davison.