Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

Describe the major elements and issues with parallel development.

Answered: 1 week ago