Note -- see the notes below!
Due in
Hand in one even numbered question+answer at the start of class.
9.5 Arguments of main
The main function in a program has arguments.
int main(int argc, char* argv[])It gets their values from the user's command. The first is a count of the number of arguments. The second is an array of old C strings (char*). The first "argv[0]" is the command the user typed! The "argv[1]" is the next word the user types. and so one. Note: argc is always one more than the subscript of the last "arg". Going past this can lead to undefined behaviors and programs crashing.
Here is an example that you should download, compile, and run: [ puzzle.cpp ]
./puzzle this is a test
The Caesar Cypher Example
[ caesar.cpp ]
Class Work
Here are two way to read a file of characters
[ 06charin1.cpp ]
and
[ 06charin2.cpp ]
-- in what way do they behave differently?
Exercises -- to think out: [ puzzle2.cpp ] [ Cat.cpp ] [ Hello.cpp ] [ outin.cpp ] [ 10.cpp ] [ attempt9.1.cpp ]
Fill in the blanks [ 06ex.cpp ]
Next -- Census Day
Last day to add or drop is
Friday.
Next -- OO Design
[ 07.html ]
and
[ uml0.html ]
Next project due at the start of session 8 -- and there is a bonus if good work is handed in at the start of the next session! Get started!
Next quiz in session 8 on material in sessions [ 04.html ] [ 05.html ] [ 06.html ] and your project.