Reference no: EM132198832
Write the following small C program:
The program is invoked as follows: reader
The program reads characters until EOF from its standard input and displays that information on screen, with at most 50 characters per line.
That is, for every 50 characters read from the input, a '\n' is added to output. For the last line, even if fewer than 50 characters are printed, add a '\n' character.
(But you must ensure that you do not have an unnecessary blank line if the number of characters in the last line is exactly 50.)
The program uses getchar and putchar for this purpose. To test the reader program, create a test file with long lines, but no '\n' at the end, and use input redirection. Use a named constant in your program for the line length of 50.
Sample output: A test file of Hellohello alternating would appear 5 times in one line as it would be 50 characters long.