simple c programming assignment 1
In this assignment, you need to write a program to the following specifications:
- In the current directory there are several files
- Some of the files in the current directory are text files containing lines of text, each line ending with the line-feed character. The names of these files end with the extension .txt.
- Write a C program that:
- Uses standard I/O functions from the C library
- Is called with three command-line arguments: a ‘find’ parameter, a ‘replace’ parameter, and a ‘prefix’ parameter
- For each .txt file in the current directory, does the following:
- Searches the file for any occurrences of the ‘find’ parameter, and replaces them with the ‘replace’ parameter
- If there were no occurrences of the ‘find’ parameter, the program searches for the ‘prefix’ parameter
- For any occurrences of the ‘prefix’ parameter, the program prepends the ‘find’ parameter to the left of the occurrence
- If there are no occurrences of the ‘prefix’ parameter, the program should do nothing to the file.
- Prints a log of its activities to stdout. The log should include the name of each text file and the type of operation done on each line.
- Be particularly careful about replacing strings of different lengths; make sure to allocate additional memory if needed! 70 Points: Program correctness
30 Points: Program documentation and code style (10), readme (10), makefile (10).
