`CISC181 honors, 02/14/06 Happy Valentines Day. ===a program that reads from a file===== Modified to do average, min, max we will return to this ====Info about Cygwin======= Last time, we had some network issues, and so we switched to running programs on my Windows PC using Cygwin. A reminder: information about Cygwin is available on the course web site: http://www.udel.edu/CIS/181h/pconrad Go to the upper left hand corner, to the link UnixAtUD The page that comes up has a link with information about Cygwin. If you have any questions or comments about cygwin, post them to the discussion boards on WebCT. ====Questions from Lab===== Were there any unresolved questions from lab how to print ? qpr -q whlps filename from pc at home running Secure Shell SSH kpr filename ====Last time===== Because of the interruption a few points may have gotten lost. Let's review: Under the folder: http://www.udel.edu/CIS/181h/pconrad/06S/lect/02.09 (Also available on strauss as: /www/htdocs/CIS/181h/pconrad/06S/lect/02.09 ) There is a folder an.incorrect.program/goodCode02.cc containing: goodCode02.cc Let's look at that code again (I've copied it into today's folder) We can compile it with: make goodCode02 That gives us an executable called "goodCode02", which we can run with ./goodCode02 We might find entering numbers from the keyboard repetitively to be tedious, so we can read from a file instead: So, the program fileOfInt.cc shows how to read those numbers from a file instead: > make fileOfInt CC -o fileOfInt fileOfInt.cc > ./fileOfInt Sorry, I could not open infile.dat > We have to actually have a file called infile.dat. A unix trick to make a quick file without going into the editor is "cat > filename" For example: > cat > infile.dat 3 5 6 1 > You hit "CTRL/D" to terminate the input. > ./fileOfInt Sorry, I could not open infile.dat > Strange, we already created infile.dat We look at the code, and find a bug... A mismatch between what we are opening "nums.dat", and what is in the error message "infile.dat" How could we have prevented this bug? one suggestion: maybe there is some way to determine the "nums.dat" from the infile variable e.g. something like infile.name() I don't know if such a thing exists, but if it does, it's a terrific idea. @@@NOTE TO SELF@@@ look into whether this exists. another suggestion: #define copy from fileOfInt.cc to fileOfInt2.cc and show how to use a #define > cp fileOfInt.cc fileOfInt2.cc > emacs fileOfInt2.cc Then we changed fileOfInt2.cc to use a #define ===more code from last time to look at=== @@@ look at each of these @@@ readInt4.cc readNums1.cc