What are some different ways I can modify a string holding ssn so that
123-45-8999 becomes XXX-XX-8999 ?
Must use string member functions to accomplish this.
Thanks!
What are some different ways I can modify a string holding ssn so that
123-45-8999 becomes XXX-XX-8999 ?
Must use string member functions to accomplish this.
Thanks!
尝试replace
:
std::string s = "123-45-8999";
s.replace(0, 6, "XXX-XX");
如果字段宽度是动态的,您可以将这个想法与我们之前所做的字符串标记化结合起来,以获得更灵活的东西。