Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program which prompts the user for a text message up to 256 characters i

ID: 3658947 • Letter: W

Question

Write a program which prompts the user for a text message up to 256 characters in length. The message should be stored in allocated memory. The program should pass the message to a function findArticles, which will locate every occurence of the words: the, a, and. For each article found, the memory address of the first character of the article should be stored in a second memory block (a dynamically allocated block of 30 pointers). Finally, the program should loop through the second memory block (in main), displaying a word for each non-zero address stored there. When searching the message, we can assume that the user will always follow an article with a space.

Explanation / Answer

#include int main () { char* search = "a","the","and"; // search pattern int offset; string line; ifstream Myfile; Myfile.open ("example.txt");//text message up to 256 characters in length if(Myfile.is_open()) { while(!Myfile.eof()) { getline(Myfile,line); if ((offset = line.find(search, 0)) != string::npos) { cout
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote