Create a program that searches user inputted substring within the text. Requirem
ID: 649682 • Letter: C
Question
Create a program that searches user inputted substring within the text.
Requirements:
Program should read the text from file (number of characters > 200).
User should be able to search different substrings in the same file (looping).
The search should be implemented using one of the following algorithms (do not use built-in search
functions!!!):
Knuth-Morris-Pratt algorithm.
If substring is found, then program should output its start position in the text. If substring is not found, then program should output appropriate message.
Explanation / Answer
/Our main function. int main(int argc, char *argv[]) { int result, errno; if(argc < 3 || argc > 3) { Usage(argv[0]); exit(1); } //Use system("cls") on windows //Use system("clear") on Unix/Linux system("cls"); result = Search_in_File(argv[1], argv[2]); if(result == -1) { perror("Error"); printf("Error number = %d ", errno); exit(1); } return(0); }Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.