I will leave the graded projects outside my door
to be picked up.
Don't forget you have the third iteration of your project
[ projects.html#P3 ]
due on Tuesday! I hope
that the readings will provide some comfort as you add at least
one loop so that the user can solve a series of problems with one
run of the program.
Reading -- Errors in Programs Pages 70-73
But one way to make conditions clear and easier to understand is to separate them. When you format code tidily you will make fewer logic errors.
Do we have a list of compiler errors and there meanings
Not as far as I know. It is worth making your own
personal list of the
errors that happen in your own programs. Practice can help a lot in finding
errors.
There is one trick is to notice the line number of the error and look backwards from that line.
file...............:Line#:....
m_n_ms.cpp:22: error: `string' has not been declared
The book lists three kinds of errors -- are there more
There are a lot of programs that do precisely what is planned and
expected of them. They fit the requirements that the programmers
were given... However they don't do what is actually needed.
We have a joke: that is not a bug, it is a feature.
These requirements mistakes are the kind of error that I am very interested in. They are quite insidious. But they are a type of logic error.
What is the most common error made by programmers
Compiler -- depends on the how much experience the programmer has. But
a common one is not declaring a variable or including a library.
Execution -- Running of the end of an array.
Logic -- off by one errors with indexes and counters.
What is the most common Execution Error that you see
Uninitialized variables. Especially when the variable is what we call
a pointer -- and is supposed to store the address of some data.
Can you identify execution errors before you run a program
I can do this fairly well -- and I write my own code with enough care
that I don't get very many -- except when I'm short of sleep.
However a complex program can defeat the best of us with an unexpected
error when it runs.
How do you copy a file using ssh
If you are logged into a Unix computer and want to copy a file
called original to a file named new then you write the command
cp original new
If you are running the Secure File Transfer Client then you can probably use the mouse to Right-Click the file and pick the 'Copy' item in the menu that pops up.
(thank for a question that taught me a new technique).
How exactly can one exploit code that has gone over the bounds of an
array
Perhaps you should go to the "Ethical Hacking" seminar the CSci club
is running.
The details depend very much on the machine and the mistake. I have an example in my cs202 labs. A badly designed login system that anybody can log into as long as they supply a long enough user name. What happens is that the user name overwrites the password field with something like 'xxxxxxxxxxx' and then you can use something like 'xxxx' to login.
Is there a program that checks for errors automatically
The complier tries to catch as many as possible. There was
a program (lint) that looked for suspicious code that was probably
an error... an example would be the following pattern
if ( ... = .... )
But Computability theory proves that there is know computer
program that will find all the errors in a computer program.
We cover the details of the proof in the CSci546.
Does C++ allow you to run the program line by line to find the errors like Visual Basic does
Yes.
What debugging aids are there in the Lab
There is a Gnu Debugger (gdb) that does this.
By the way -- it is a command line debugger and so can be used remotely via SSH. The KDE provides a GUI front end called "kdbg" that is under the "Start"->Deveopment->KDbg menu.
You can find out more [ Gdb ] on the Wikipedia.
On the other hand find most debuggers harder to use than thinking and planting extra outputs. I don't use it enough to be any good at it or to give you instructions and advice. I have a CS202 lab that Dr. Zemoudeh wrote that showed how to use gdb.... but I've discarded it in recent years. To be honest -- I feel debuggers are for wimps:-)
A number of people have asked about these debuggers. I will see what documentation I can find... TBA.
What is the difference between a compile error and a logic error
Suppose that we programmed in English then
Cat the mat on sat.is a compile (syntax) error. But
Poor oil on burning water.is a logic error.
In other words a logic error follows all the rules of the language but instructs the computer to something bad or at least unexpected.
Will a program with logic errors compile
Yes.
How can this happen
Because commands can make perfect grammatical sense and still be
bad. Computers don't understand this and do it anyway. The
key point of computer science is that computers are stupid but
follow instruction precisely as written. Badly chosen instructions lead
to erroneous behavior. The logic of the program is broken.
It can be quiet subtle.
For example: my wife is a substitute teacher for SBUSD but
the new computer program can not be told that she is not in the
house with out inputting her PIN... and a lot of other stuff.
This compiled, runs, and makes us both want to smash the telephone.
I class this as a logic error. Bit notice the program must have
compiled an run without an execution error.
Is there any reason for not using double
Don't use double when you want to exact answers.
As a rule you only use int's for counting. If you notice that you are doing lots of multiplications, and you don't mind an approximate answer then you can use double.
There is another solution to the problem when you want to do precise (integer) calculations with very large integers. It is not a simple solution: you must use an vector of int's to represent numbers and work out operations for multiplying, adding and subtracting using multi-length arithmetic your self -- or hunt for the functions and classes on the Web.
I'd love to spend time on this but it is not a very useful technique for everyday programmers. Perhaps I'll be able to put it in a future lab!