MCS 275 homework #3 Due date: 19990312 D. J. Bernstein In the following exercises, use getchar to read characters, and putchar to write characters. Do not use other C string library functions. Exercise 5. Write a search program that reads lines of input and prints every line that contains a target string. The target string is a command-line argument, argv[1]. For example, search foo will print the

lines foo, foobar, fofoo, and testfootest, but not bar or fofo or f.

You may assume that each line contains at most 1000 characters. Exercise 6. Write a double program that prints two copies of its entire input. For example, if the input is

foo\nbar\n, double will print foo\nbar\nfoo\nbar\n.

Your program must be able to handle as much input as fits into memory. If memory is full, print an error message and stop immediately. Use the following approach. Put the input into an allocated array. Keep track of how much space you have allocated. When the number of bytes of input equals the amount of space allocated, allocate a new array with twice as much space, and copy the input to the new array.