Ignoring Newline, Tab and Blank Characters in Input
Lines 87–90 in the
switch statement of Fig. 5.10 cause the program to skip newline, tab and blank characters. Reading characters one at a time can cause problems. To have the program read the characters, we must send them to the computer by pressing the Enter key. This places a newline character in the input after the character we wish to process. Often, this newline character must be specially processed. By including these
cases in our
switch statement, we prevent the error message in the
default case from being printed each time a newline, tab or space is encountered in the input.