NOTE: ACM Meeting Tonight 7:00pm 104 Gore. Speaker Jerry Heinz -- hiring in small technology companies and the difference between east and west coast companies.
Read: D&D, through p. 370 (through 5.12), pp. 404-411 (through 6.4).
Exercises due Thursday, April 7, Write (and test) a program that takes a string of someone's name and prints it out last name first. Your program should use pointers (not array subscripts). You may use the available string manipulation functions if you find an opportunity. Example,
"George Washington"
Washington, George
Forget what you named that file? The grep command may help. grep is used to
search for files that contain the argument grepped for. E.g.,
grep -i cd *
looks for the sequence "cd" in all of the files in the current directory. The -i
flag says to ignore the capitalization when doing the search. (Note: the * is a
"wildcard" in unix. It matches anything.)
For example, in the directory that I did some old class work in, I did the
following grep command and got the following results:
ren[2:05pm] [~/cisc181.97f/]> grep -i cd class*
class09.oct2:The cd command is used to change directories. E.g.,
class09.oct2:cd $CLASSHOME/examples
class09.oct2:cd ..
class09.oct2:cd
class09.oct2:cd ~username
class09.oct2~:The cd command is used to change directories. E.g.,
class09.oct2~:cd $CLASSHOME/examples
class09.oct2~:cd ..
class09.oct2~:cd
class09.oct2~:cd ~username
class13.oct16:alias cd.. 'cd ..'
The command restricted the search for cd to be among the files that begin with "class". The system response tells me that three files contain the sequence I am looking for: class09.oct2, class09.oct2~, and class13.oct16.
fn_name(type * typePtr) -- neither the data nor the pointer are constants so both may be changed within the body of the function see: $CLASSHOME/deitel-files/examples/ch05/fig5_10.cpp
fn_name(const type * typePtr) -- here the data is constant, but the pointer may be changed within the function, see: $CLASSHOME/deitel-files/examples/ch05/fig5_11.cpp Note -- only the data being pointed to is being passed call-by-reference, the pointer itself is passed call by value. Changes to it are not reflected in the calling program. See: $CLASSHOME/deitel-files/examples/ch05/fig5_11.cpp
fn_name(type * const typePtr) -- here the data can be changed, but the pointer itself cannot be (but see the note above anyway!). This SHOULD be the way the swap function in figure 5.15 was implemented. To see it in use, see the file: $CLASSHOME/deitel-files/examples/ch05/const-5-15.cpp Note -- if this were an array, then having a const pointer would mean that array subscript notation would need to be used to access the array elements. (That is what is the case in the bubble sort -- so the updated file has const there too!)
fn_name(const type * const typePtr) -- here the data and the pointer are both constants. Notice how the program in figure 5-11 can be rewritten this way -- using array subscript notation instead of pointer-incrementing. See the file: $CLASSHOME/deitel-files/examples/ch05/const-const-5-11.cpp