Question
Hello, I need help solving this Lab simulation, It uses remove spaces for loops statements and I am very new at coding on so I
Hello, I need help solving this Lab simulation, It uses remove spaces for loops statements and I am very new at coding on so I need help solving it. It is very difficult. It is very confusing since the there are multiple inputs and on can only code it once.
A program that removes all spaces from the given input. If the input is "Hello my name is John." the output is "HellomynameisJohn."
try these inputs as well:
If the input is "This is a sentence." the output is "Thisisasentence."
If the input is "Look! Multiple spaces." the output is "Look!Multiplespaces."
If the input is "Look! Multiple spaces." the output is "Look!Multiplespaces."
If the input is "flying" the output is "flying"
but the problem is that you can only code one input, so you can only remove the spaces on one input but I need to remove all the spaces on each input in this lab simulation.
#include
using namespace std;
int main() {
/* your code here. */
return 0;
}
Here is a clue my friend in the class sent me
The following code will remove spaces from your input
Example:
if you type "This is a test"
your output will be:
Thisisatest
#include
#include
usingnamespacestd;
intmain() {
stringuserInput ="";
stringuserInputNoSpaces ="";
unsignedinti;
std::getline(cin, userInput);
for(i = 0; i < userInput.length(); ++i) {
if(!isspace(userInput.at(i))) {
userInputNoSpaces+=userInput.at(i);
}
}
cout< return0; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started