CS 105: C++
Project 4 Required Concepts
C: Chapter 6, 7

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

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

  3. 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 ?

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

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

  6. Be able to write simple scanf statements to read things like ints, floats, and strings.  Important: How can scanf save what it reads into your variables if all function calls in C are pass by value?  Does this work the same for scanf reading into ints as it does for reading into strings?  (Even more important: If you handle this wrong, bad things can happen.)

  7. What is sprintf?  What is the simple change required to turn a printf statement into an analogous sprintf statement?  (Note: In my experience, sprintf is very useful.)

  8. Is there something similar for scanf?

  9. Be able to fill in the blanks below so that the word "test" is written into the file "test.txt", and understand the purpose of each line.

      ____ *fp;                 /* Declare the file pointer. */
      fp = fopen(____, ____);   /* Open the file for writing. */
      fprintf(____, "test\n");  /* Write the text to the file. */
      ____(fp);                 /* Close the file. */
  10. Understand the basics of malloc and calloc, including what they do and how they differ.  How is "sizeof" commonly used in calloc calls?  "free" is used to undo the work of malloc; is "free" used in the same way with respect to calloc?

  11. Know how to use rand() to write an expression that produces a random integer between 1 and 10 (inclusive).  (Note: You'll probably need to use "%" and "+", and your first guess may not be correct.)




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