In this assignment you will write a C filter program that processes input text by expanding macros found in the text. The values that the macros will expand to will come from either command line arguments or environment variables. This assignment makes use of files contained in this zip file.
Write a C program that reads from standard input and writes to standard output. Any character read from standard input that is not part of a macro should be written directly to standard output. When your program finds a macro in its input, it will "expand" (i.e., replace) the macro with a certain text string. In this assignment, a macro is defined to be a string of the form In the zip file for this assignment you will find a sample text file that you can test your program with. Also in the zip file is a Windows batch file that automates the testing of your program with the sample input file (the batch file demonstrates how to set environment variables and how to use I/O redirection to process files). Another text file contains the correct output that your program should produce when the batch file is run. Turn in a zip file containing your C program that solves this problem, the original sample input text file, the original batch file, and any other test files that you want to include. This assignment is due Monday, January 26. Below are some references about I/O redirection, command line arguments, environment variables, and thegetenv() function.
|