Objective
Add the missing code to create a program that will highlight user designated words.
Requirements
- Input Handling
- The program must take a file name as an argument and open the file for reading.
- The file will contain a list of words (aka a sentence), with one sentence per line.
- The program will read a keyword from the user via standard input (stdin).
- File Processing
- Get user's keyword from standard input
- Read from the provided file
- Remove the newline character from the end of each line read from the file (if present)
- Process each line of the file character by character
- Set the word variable to an empty string (hint set position 0 to null terminator)
- Copy the characters to the word variable until a space or the end of the line is reached
- Set the location after the last character copied to null terminator (to end the word)
- If a word in the line matches the user's keyword (strcmp == 0)
- If strcmp is 0 then, surround the keyword in the line with asterisks (**) on each side and copy to the result c-string
- If strcmp is not 0, then copy the current word to the result c-string
- Add a space to the result c-string
</ul>
- Output
- The program should print the modified text to standard output (stdout).
Steps to Complete
- Implement the requirements (see CODE comments in main.c)
- Compile and test the program
- Create a test file with a sentence or two
- Test the code's functionality by running the program with the test file as an argument and entering a keyword when prompted.
- Once working correctly, run /challenge/tester
- Get flag