/* Chapter 3: file README03.c */ C++ code for Chapter 3 of Programming Languages: Concepts and Constructs, by Ravi Sethi, Addison Wesley, 1996 The files are table.c uniq1.c uniq2.c The two versions uniq1.c and uniq2.c illustrate the C++ and C approaches input/output. ------------------------------------------------------------------- FILE: uniq1.c PROGRAM: uniq PURPOSE: Illustrates C++ input/output using SEE: A Pascal version is in file uniq.p COMMENT: The input stream is called "cin"; the output stream is called "cout". The input operator is >> so the statement cin >> x; reads into x. The type of x determines what is read into x. SImilarly, the output operator is <<, so the statement cout << x << '\n'; writes x and then the character '\n'. With the input 1 1 2 2 2 3 1 4 4 0 program uniq produces the output 1 2 3 1 4 ------------------------------------------------------------------- FILE: uniq2.c PROGRAM: uniq PURPOSE: Illustrates C/C++ input/output using SEE: A Pascal version is in file uniq.p COMMENT: With the input 1 1 2 2 2 3 1 4 4 0 program uniq produces the output 1 2 3 1 4 ------------------------------------------------------------------- FILE: table.c PROGRAM: table PURPOSE: C++ counterpart of Pascal program in file table.p SEE: Comments for file table.p in file README03.p COMMENT: C++ input/output using is briefly described in the comments above for file uniq1.c. Program table reads a list of integers and writes out an integer if it has not already appeared in the list. With input 1 1 2 2 2 3 1 4 4 0 program table produces the output 1 2 3 4 -------------------------------------------------------------------