plz help me I have a program source code of C++ that eliminate or delete too spa
ID: 3616002 • Letter: P
Question
plz help me I have a program source code of C++ that eliminate or delete too spaces of text like if you writeor input character string (computer man college)... so the out putwill be
(Computer Man College).....
so my question is I want to add like if I write or input anyletters like (m) the output will be
m = 3,9
or if I input letter like (c)
c = 1,14
So here is the source code that eliminate or delete spaces ofthe text.
#include <iostream>
using namespace std;
int main()
{int i,j=0;
string s;
char newstring[100];
char last='1'; //set to anything butblank
cout<<"enter a string: ";
getline(cin,s);
for(i=0;s[i]!='';i++)
{
if(s[i]==' ')
{if(last!=' ')
newstring[j++]=s[i];
}
else
newstring[j++]=s[i];
last=s[i];
}
newstring[j]='';
cout<<" original string: "<<s<<endl;
cout<<"new string: "<<newstring<<endl;
system("pause");
return 0;
}
Explanation / Answer
please rate - thanks #include using namespace std; int main() {int i,j=0; string s; char newstring[100]; char last='1'; //set to anything butblank coutRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.