Exam 1
Review

The exam will be on

Thursday, 3 March 2005, 9:30 - 10:45 am.


Quizzes: Study quizzes 0, 1, 2, and 3 for the topics to be covered on the exam


Recitations: You should also study Recitations 1 through 6.


Practice creating a string: Let's suppose you read up to a newline, and create a string from the characters you have read. We talked about several ways to do this in class, using two kinds of buffers and three types of string creation. Here are the two buffers, each of size 100 bytes:

There are two significant differences between these two buffers:

  1. Storage for the first buffer will be automatically reclaimed as you leave the block in which it was declared. Storage for the second method must be explicitly reclaimed using the command: free(buff2);.
  2. The variable buff1 is a constant pointer to char (address of a char) and cannot be incremented or modified at all. The second variable buff2 is a pointer variable that can be changed or incremented.

As practice for the exam, write code that will read chars to a newline and will use each buffer to create a string, using index notation, pointer notation, and pointer arithmetic notation. Answer: buffer use.


Copyright © 2011, Neal R. Wagner. Permission is granted to access, download, share, and distribute, as long as this notice remains.