9.6. SCANFILE: Input and Output with Files
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.
Figure 9-5. SCANFILE: Using C-like input and output with files
// 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" ... |
Get Itanium® Architecture for Programmers: Understanding 64-Bit Processors and EPIC Principles now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.