9.7. SORTINT: Sorting Integers from a File

As a second example of working with files, we present a companion to the SORTSTR program, which performed a bubble sort on strings entered interactively. The SORTINT program (Figure 9-6) reads integer quantities from an ASCII text file into internal binary storage as quad words, sorts them using the bubble sort algorithm, and writes the ordered list of signed integers to a new text file, one per line. This program utilizes I/O features of the SCANFILE program to implement the bubble algorithm of the SORTSTR program.

Figure 9-6. SORTINT: Bubble sort for integer quantities
 // SORTINT Bubble sort integers from a file // This program will read 100 or fewer integers from a // text file, sort them using the ...

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.