CS 105: C++
Quiz 6 Requirements
C: Chapter 6

  1. Know how to write a simple struct declaration (like the declaration of "struct point" at the beginning of the reading).

  2. Understand how to declare a variable of a struct type as a part of the struct declaration.

  3. Understand how to declare a variable of a struct type in a separate statement.

  4. Know how to access (read from/write to) the members of a struct.

  5. Accessing a struct's members through a pointer to the struct is probably even more common than accessing a struct's members directly.  Know how to do this both with and without the structure pointer operator ("->", also called "arrow").  Also: If you don't use the arrow operator, are parentheses necessary?  In other words, if pp is a pointer to a structure, is *pp.x okay, or do you need (*pp).x ?

  6. Know what sizeof does and how to use it on simple types.  (Does it work on arrays and structs, too?)

  7. Be able to write (very simple) typedef declarations.  (But be aware of the required order in such a statement.)

  8. Using a struct to define nodes for things like trees and linked lists is extremely common and useful in C (and it's something you'll need to do in Assignment 4).  Can you write a struct declaration for a node in a simple linked list?  (Assume, for example, that the node stores a single int and a pointer to the next node in the list.)

  9. Understand how storage space for dynamically allocated nodes is obtained by calls to malloc.  For example, a malloc call might look something like this:

      struct node *head = (struct node *) malloc(sizeof(struct node));

    Understand what's being passed as an argument to malloc.  Why does the result of malloc need to have its type cast?  If memory is allocated with malloc, how is it deallocated?



Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.