Replace any space ' ' with '_' in 2-character string passCode. Sample output for the given program:
1_
#include <iostream>
#include <string>
#include <cctype>
using namespace std;
int main() {
string passCode;
passCode = "1 ";
/ Your solution goes here /
cout << passCode << endl;
return 0;
}
The answer is :
for(unsigned int i = 0; i < passCode.length(); i++){
if(isspace(passCode.at(i))){
passCode.at(i) = '_';
}
}
Post a Comment
Post a Comment