Question: I am having trouble turning the string into a getline function so that a user can input html tags via the keyboard to be removed.

I am having trouble turning the string into a getline function so that a user can input html tags via the keyboard to be removed. I was also needing some help on moving them into functions I always have trouble doing so, but here is my instruction and code so far.

Instructions:

No Global variable can be used.

Write a program that will receive a string value via the keyboard from a user and then remove any html tags from that value.

Example: I enter:

Hello

There

Output to screen: Hello There

*NOTE: Don't worry if you are not getting spaces correct in the output. I am only interested in your programming remove the strings we don't want.

There should not be any html tags in your output. The user is free to enter anything he/she wants, so it is not limited to the above example. So, your program needs to be able to remove any number of html tags entered.

Functions: I am expecting to see 3 functions in your program:

Get the string value from the user via the keyboard

Process the string value where you remove all html tags

Output the updated string to the screen

Current code:

#include #include

using namespace std;

int main() { string text = "

Hello

There";

cout << "Original HTML: " << text << endl;

for (int a = 0; a < text.length(); a++) { if (text[a] == '<') { for (int b = a; b < text.length(); b++) { if (text[b] == '>') { text.erase(a, b - a + 1); a--; break; } } } } cout << "HTML Removed: " << text << endl;

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!