Main Requirements:
1. You absolutely must use the program template main.txt file. You cannot modify prototypes or code inside main() function! You must add required header files and create functions using the function prototypes set in the template. You’ll get a -3 points penalty if this requirement not met.
2. Please check output.txt file – that’s the file your program must generate (OUT_FILE macros).
3. Please check image1.png file – that’s the console output your program must show!
4. You must use defined MAX_QUOTES (maximum number of quotes that can be read from the quotes.txt file) and MAX_LEN (maximum length of the string input in fgets() function.
5. Your program must correctly allocate memory on the HEAP for each quote (i.e. for each element of the array of pointers quotes). You’ll get a -3 points penalty if this requirement not met.
6. You must check and deal with potential problems with memory allocations or file IO. For instance, malloc/calloc can return 0, file(s) cannot be opened or created, there are more quotes in the file than MAX_QUOTES, etc.
7. Your program must still work if the number of quotes in the file exceeds MAX_QUOTES. Please provide a notification about that, but do NOT terminate the program – i.e. stop reading quotes from the file in the read_in() function and continue with the rest of the program. Please test this by settings MAX_QUOTES to 5,6,7. Please check image2.png that shows what happens when MAX_QUOTES is set to 7.
8. You must use Selection Sort algorithm to sort by length of the quotes. No other sorting algorithm will be accepted! Quotes with the same length must be sorted lexicographically.
9. Your solution should have optimal time and space complexity, and modular design.
There should be no compilation warnings or commented out "debugging" code.
Get Free Quote!
366 Experts Online