# include \"stdafx.h\" # include<iostream> #include <string> using namespace std
ID: 3644406 • Letter: #
Question
# include "stdafx.h"# include<iostream>
#include <string>
using namespace std;
int main()
{
string str,s1,s3,s;
cout<<"Enter string:";
getline(cin, str);
s=str;
do
{
s1 = s.substr( 0, s.find_first_of( ' ') );
for (int i= 0; i<s1.length(); i++)
if (!isdigit (s1[i]))
break;
else
s1[i]= 'x';
s = s.substr ( s.find_firs_of(' ')+1 );
s3.append (s1) ;
s3.append ( " );
}
while ( s.find_first_of (' ') < s.length() );
s3.append ( s );
cout<< "Output: "<<s3<<endl;
system ("pause");
return 0;
}
I am getting errors on this proram not sure why. I am trying to input
john 17 1234 and outut john 17 xxxx
Explanation / Answer
// string constructor #include #include using namespace std; int main () { string s0 ("Initial string"); // constructors used in the same order as described above: string s1; string s2 (s0); string s3 (s0, 8, 3); string s4 ("A character sequence", 6); string s5 ("Another character sequence"); string s6 (10, 'x'); string s7a (10, 42); string s7b (s0.begin(), s0.begin()+7); coutRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.