April 2003
Intermediate to advanced
576 pages
15h 13m
English
Figure 9-5 continues the progression of SCANTEXT and SCANTERM by presenting SCANFILE. We have designed a program that loops through an input text file and places into an output text file each isolated word (with any trailing punctuation) on a separate line. The SCANFILE program also counts the number of words, which will be the number of lines in the output file, and displays that value on the screen.
// SCANFILE Demonstrate I/O for files // This program does lexical analysis by reading "words" // from a text file using fscanf. These separate words are // then written out, one per line, using fprintf. BUFL = 80 // Allowance for a "word" ... |