Question: We are using C++ for this. Example: I enter: Hello There Output to screen: Hello There There should not be any html tags in your
We are using C++ for this.
Example: I enter:
Hello
ThereOutput to screen: Hello There
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
This is my code I have so far, I am only able to get rid of the " tags. The "
are still there.
#include
using namespace std;
int main() { string name; cout << "Enter a textual value: "; // Enter your html tags here getline(cin, name);
int a = 0, b = 0;
for (int a = b; a < name.length(); a++) { if (name[a] == '<') { for (int b = a; b < name.length(); b++) { if (name[b] == '>') { name.erase(a, (b-a+1)); break; } } } }
cout << "Updated String Value: " << name << endl; // Will output what your new text will be
return 0; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
