Question
//I NEED THE PROGRAM IN C LANGUAGE!// QUESTION: I need you to write a program which manipulates text from an input file using the string
//I NEED THE PROGRAM IN C LANGUAGE!//
QUESTION:
I need you to write a program which manipulates text from an input file using the string library. Your program will accept command line arguments for the input and output file names as well as a list of blacklisted words. There are two major features in this programming:
1. Given an input file with text and a list of words, find and replace every use of these blacklisted
words with the string REDACTED . You are essentially creating a tool for redacting, or
censoring, blacklisted words. Think of the classified government memos with the important bits
blacked out.
2. Given the same input file, report the number of characters and then number of words present in
the text.
Because we have not yet covered file I/O, routines for reading and writing strings to files will be
provided. The routines come in the form of a pre-compiled object file and accompanying header file
Required functionality:
1. Accept command line parameters for the following
a) Input file name
b) Output file name
c) List of black listed words to be remove from the input file text
See the Input/Output Requirements section for details on the format of your program inputs
2. The censoring functionality has the following requirements
a) The text to censor is read from the input file specified on the command line. Use the
readFromFile() function provided to do so
b) In this text, look for and replace every instance of the blacklisted words provided on the
command line with the word REDACTED
c) Write the censored text to the output file specified on the command line. Use the
writeToFile() function provided to do so
You can assume following
There will be no more than 20 blacklisted words input on the command line
There will be no more than MAX_CHAR_COUNT/2 number of characters in the input file.
This constant is specified in the fileUtils.h file
3. Before censoring the text from the input file
a) Find the number of characters in the text (this includes spaces, newlines, or any valid
character). Write the results to output file.
b) Find the number of words in the text and write the result to the output file
4. You must use functions from the string library to manipulate the text
5. Your program must be split up into multiple files
a) A .c file with all manipulation and count related function implementations
b) A .h file with all macros and function definitions for the above .c file
c) A .c file that contains your main and any other functions
6. A makefile to compile your program
a) All of your source files should be compiled with c99 and the -Wall option
b) An example will be provided
Suggestions
The following string library functions could be useful
strlen
strcpy
strncpy
strcat
strncat
strtok
strstr
You will need to include the fileUtils.h file in your code wherever you use the
readFromFile() and writeToFile() functions
You can use a diff tool to compare the file output from your program to the expected, correct
output. There is a diff command available on linux.
Input/Output Requirements:
1. The syntax for running your program should be
programName input.txt output.txt word1 word2 word3
input.txt - File containing text to be censored
output.txt - File where censored text and counts are written
word1 word2 - The words that should be censored from the input text
2. The format of the output file should adhere to the following standard
CHARACTER COUNT
WORD COUNT
CENSORED TEXT
Each of these items is started on a new line. The censored text should have the same format as
the original text, with only the blacklisted words being replaced with REDACTED
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started