A Larger Example of Encapsulation
The next example is input expression verification. Again, for simplicity sake, I will limit the functionality of the example to verifying whether parentheses and brackets in the input expression properly match each other. Let us consider a function checkParen() that scans the characters of the expression in a null-terminated array one-by-one until it either finds the terminating null (end of expression) or it discovers a parenthesis or a bracket that does not have a match. For example, the expression a = (x[i] + 5)*y should be recognized as a valid expression, and the expression a = (x[i) + 5]*y should be declared invalid.
The example will use two global arrays, buffer[ ] and store[ ]. Index i retrieves a character ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access