Pure Programmer
Blue Matrix

Cluster Map

Project: Line Number Filter

Write a program that accepts input from the console or from a re-directed file that prints each line from the input stream. Each line should be prefixed with a line number (padded to 5 spaces, right aligned), followed by a colon, followed by the line from the input stream.

$ g++ -std=c++17 LineNumberFilter.cpp -o LineNumberFilter -lfmt $ ./LineNumberFilter < ../../data/text/jfk11.txt 1: JFK's Inaugural Address, January 20, 1961, 12:11 EST 2: 3: We observe today not a victory of party but a celebration of freedom, 4: symbolizing an end as well as a beginning, signifying renewal 5: as well as change for I have sworn before you and Almighty God 6: the same solemn oath our forbears prescribed nearly a century 7: and three-quarters ago. 8: 9: The world is very different now, for man holds in his mortal hands 10: the power to abolish all forms of human poverty and all forms of human life. ... 124: do for you, ask what you can do for your country. My fellow 125: citizens of the world, ask not what America will do for you, 126: but what together we can do for the Freedom of Man. 127: 128: Finally, whether you are citizens of America or citizens of the world, 129: ask of us here the same high standards of strength and sacrifice 130: which we ask of you. With a good conscience our only sure reward, 131: with history the final judge of our deeds; let us go forth to lead 132: the land we love, asking His blessing and His help, but knowing that 133: here on earth God's work must truly be our own.