9.3. SCANTERM: Using C Standard I/O

We presented in Chapter 6 the simple SCANTEXT program to scan through a stored string, byte by byte, looking for space characters as separators between words. That program, like many of our other illustrations, had no provision for I/O outside of the debugger.

We will rework the SCANTEXT program to add input and output from the “terminal” (i.e., the keyboard and display), using external calls to standard C library functions (Table 9-1). The new SCANTERM program in Figure 9-3 displays a prompt with puts, obtains a line of input using gets, counts the number of words and the total number of characters, and then prints a summary line containing two embedded numeric fields in decimal radix using printf.

We encourage ...

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.