CMPT 127 Lecture Notes - Lecture 8: Indent Style, Standard Streams, Scanf Format String
Document Summary
The previous task produced a very fragile program. Assuming your code perfectly meets the requirements above, you can say it is correct. But correct is defined by reference to the requirements. This code is not robust when the user is free to type in arbitrary things into standard input. We can improve the requirements by specifying what the program should do in the case of failures. It is important to see that correct code may not be reliable in the real world, and that the task of specifying requirements is a large part of the work of programming. To write robust software that does the right thing even when used roughly, we first need to extend the requirements to specify what to do when things go wrong. Then in the code we test things as we go along, using conditionals: keywords that change the program"s behaviour depending on the value of a statement at the time it is executed.